Next.js Discord

Discord Forum

API returns Internal Server Error but webpage works

Unanswered
Scale parasitoid posted this in #help-forum
Open in Discord
Scale parasitoidOP
I'm having an issue with one of my API routes. When querying the API from Postman it returns Internal Server Error.

In the console I get the error in the image. I should mention that I am on an M2 macbook Pro, and this error doesn't show up in my M1 Mac mini for example. I tried googling but cannot find an answer to the problem. Anyone has any idea what the issue could be?

2 Replies

Scale parasitoidOP
This is what happens in Postman
Scale parasitoidOP
`
import { PrismaClient } from "@prisma/client";
import { NextResponse } from "next/server";

const prisma = new PrismaClient();


export async function GET(){
    
    try {
        const data = await prisma.country.findMany();

        res.status(200).json(data);
    } catch (error) {
        return {"message" : "there was an error"}
    }

}
`