OccultSlolem
OccultSlolem•3y ago

generic error

I'm gettting a generic "Your request couldn't be completed" error when calling my endpoint. The logs on Convex aren't acknowledging that the call is being made. Something I noticed is that my action never popped up on the functions list, I'm wondering if I maybe ballsed it up somehow.
curl -H 'content-type: application/json' "https://charming-wolverine-861.convex.site/promptModel"

> {"code":"InternalServerError","message":"Your request couldn't be completed. Try again later."}
curl -H 'content-type: application/json' "https://charming-wolverine-861.convex.site/promptModel"

> {"code":"InternalServerError","message":"Your request couldn't be completed. Try again later."}
14 Replies
OccultSlolem
OccultSlolemOP•3y ago
This is my action
import { action } from "./_generated/server";

export default action(async ({}) => {
const response = await fetch('https://api.openai.com/v1/models', {
method: 'GET',
headers: {
Authorization: `Bearer sk-redacted`,
}
});

return await response.json();
});
import { action } from "./_generated/server";

export default action(async ({}) => {
const response = await fetch('https://api.openai.com/v1/models', {
method: 'GET',
headers: {
Authorization: `Bearer sk-redacted`,
}
});

return await response.json();
});
basically my endpoint from earlier but extracted into an action
nipunn
nipunn•3y ago
is it showing up on the dashboard?
OccultSlolem
OccultSlolemOP•3y ago
nah :[
nipunn
nipunn•3y ago
npx convex dev (or in some of the tutorial projects, npm run dev is good enough) - makes sure that functions get synced over to Convex and show up on the dashboard
OccultSlolem
OccultSlolemOP•3y ago
I'm not getting any errors from npx convex dev or the logs either yeah im doing convex dev
nipunn
nipunn•3y ago
hmmm, one thing is that actions have to be in convex/actions/ directory
nipunn
nipunn•3y ago
if it's working right it'll look something like this. Here's a screenshot from one of my apps
No description
nipunn
nipunn•3y ago
(I have an action in a file called page.ts
OccultSlolem
OccultSlolemOP•3y ago
that would do it. I'm back to where we were originally though: fetch is not defined
nipunn
nipunn•3y ago
gotta do the standard node-fetch thing in your package.json
OccultSlolem
OccultSlolemOP•3y ago
No description
nipunn
nipunn•3y ago
npm
node-fetch
A light-weight module that brings Fetch API to node.js. Latest version: 3.3.0, last published: 3 months ago. Start using node-fetch in your project by running npm i node-fetch. There are 29684 other projects in the npm registry using node-fetch.
OccultSlolem
OccultSlolemOP•3y ago
I just npm installed node-fetch but it's still doing it oh wait i probably have to import it lmao sick it works preciate ya
sshader
sshader•3y ago
Thanks for the report of the generic error! Better error message is in the works 🙂

Did you find this page helpful?