How to set request body in useCustom
How can I set an object as the request body of a post request using useCustom? I currently have it set as the config.query value, but that's not getting picked up by my backend server.
2 Replies
Hi @HypnoticMeat. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To set an object as the request body of a POST request using
useCustom
in refine, you should use the config.payload
property. The config.query
property is used for query parameters, which is why your backend server is not picking it up as the request body.
Here is an example of how you can set the request body using config.payload
:
In this example:
- url
specifies the endpoint of the request.
- method
specifies the HTTP method, which is "post" in this case.
- config.payload
is used to specify the request body.
For more details, you can refer to the official documentation (https://refine.dev/docs/data/hooks/use-custom/#configpayload).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@224018850419572736> kapa.ai is still learning and improving, please let us know how it did by reacting below