`body` vs `params` option
Describe the change
In the documentation it is advised to use body with a POST request to pass data. Though in my Symfony API the user and password property were both null despite the payload containing them both.
After looking through the code i saw the params option which worked.
Any plans on explaining this in the docs? I did not find the params option in the README
code in question:
const data = await $fetch("/login", {
method: "POST",
params: { usr: "user", pwd: "password" }, // body did not work
baseURL: config.public.baseURL,
})
URLs
No response
Additional information
- [X] Would you be willing to help?
Invalid Issue / Question
params option is an alias for query. The payload you provided, (usr and pwd) were included in the URL query, instead of being sent as POST body. The final request was POST /login?usr=user&pwd=password. Unless you meant to transfer the payload via query, you should have used body instead. The issue is with your "Symfony API" not the ofetch library. Likely you are reading the body incorrectly there.