Back

[SOLVED] functions.createExecution data is a string, while data is expected as json?

  • 0
  • Web
Camo
30 May, 2023, 13:42

functions.createExecution data is a string, while data is expected as json? I'm trying an example function, how would I pass the data if sdk expects string? js deleteArticleFunction: async (id:string)=>{ await functions.createExecution("TestFunction", {remove:id}, true) },

TL;DR
Solution: The issue occurs when passing data to the `functions.createExecution` method in the Appwrite SDK. The data is expected to be in JSON format, but it is currently being passed as a string. To solve this, you need to parse the data before passing it to the function. Here's the updated code snippet: ```js deleteArticleFunction: async (id:string)=>{ await functions.createExecution("TestFunction", JSON.stringify({remove:id}), true) }, ``` By using `JSON.stringify`, you are converting the data into a JSON string before passing it to the function. This should resolve the issue.
Binyamin
30 May, 2023, 13:44

Stringify it, like such

TypeScript
await functions.createExecution("TestFunction", JSON.stringify({remove:id}), true)
Binyamin
30 May, 2023, 13:44

Then, inside your function parse it

Camo
30 May, 2023, 13:49

Cheers

Binyamin
30 May, 2023, 13:51

btw, in G4 of Appwrite function you'll probably won't need to that https://github.com/appwrite/appwrite/discussions/5016

Camo
30 May, 2023, 14:03

looks great, hopefully will come with github integration for functions

Camo
30 May, 2023, 14:43

[SOLVED] functions.createExecution data is a string, while data is expected as json?

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more