Using Action
Hey,
I am new to convex. I have written a mutation function for my application. The function needs to call an API to get the user ID of an individual. I get this error when I save my file. error: archive defined in documents.js is a Mutation function. Only actions can be defined in Node.js. I am not familiar with actions. Can someone help me?
2 Replies
@NanaGaisie Since you're calling a 3rd party API you'd want to use an Action for that part: https://docs.convex.dev/functions/actions
And you can write the Mutation inside of the Action as the subsequent step.
Actions | Convex Developer Hub
Actions can call third party services to do things such as processing a payment
Hey @NanaGaisie, remove “use node” from the file, or move the mutation to another file.
Like Omar said fetch can only be called from an action.
Also note that the function always runs in the cloud, so you cannot call endpoints on localhost - you’d need to use a deployed server, or move the logic from kindeSession into a Convex function.