input coming back as undefined
Hi, I'm trying to implement a new action in, but my input args keep coming back as undefined.
Here's is the flow I've followed from the docs
curl eample:
main.wasp
@src/user/operations
std.out
6 Replies
Hi @ayo. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the information provided in your question and the knowledge sources available, I can offer some insights and suggestions regarding your issue with the
followUser
action in Wasp.
The problem you're experiencing, where the input args are coming back as undefined, is likely related to how you're calling the action and passing the arguments. Let's break this down:
1. Action Declaration:
Your action declaration in main.wasp
looks correct:
2. Action Implementation:
Your implementation in @src/user/operations
also looks correct:
3. Calling the Action:
The issue might be in how you're calling the action. According to the Wasp documentation on Actions (https://wasp-lang.dev/docs/data-model/operations/actions#using-actions), when you call an action, you should pass the arguments as a single object.
Your curl example shows that you're passing multiple fields in the JSON payload:
However, your action implementation is only expecting followingId
. This mismatch could be causing the issue.
To fix this, you should modify your action call to only send the followingId
:
If you need to pass more fields, you should update your action implementation to expect them:
Additionally, make sure you're importing and using the action correctly on the client side. If you're calling it from the client, you should import it from wasp/client/operations
as mentioned in the Wasp documentation (https://wasp-lang.dev/docs/data-model/operations/actions#declaring-actions-in-wasp).
If you're still experiencing issues after making these changes, you might want to double-check your server logs for any error messages, and ensure that your Wasp and Node.js versions are up to date.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @ayo, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?I've also tried
Using actions directly to cURL is not something we support i.e. we don't give you any docs on how to do it.
If you check how actions' data is sent when they are invoked by the client you'll notice that the JSON payload is not exactly what you think it is. We are using SuperJSON to serialise the payload and it's wrapped in one extract object.
{"json": <your-data>, "meta": <superjson-info>}
You can just wrap it with "json"
and leave out "meta"
if you are not sending any Dates or other complex data types.Thank you for the response. That helped me get the feature going 🙌 . Also welcome back!
cURL was just so I could provide an example here. I'm using bruno for endpoint testing
I'm glad you figured it out 👍 how's working with Bruno? I've heard about it, but didn't use it
Bruno I find pretty good. both in my 9-5 and on this project. Without needing enterprise version, I can do all I want