Able to fetch data through axios #172
hkhattabii
started this conversation in
Ideas
Replies: 1 comment 2 replies
-
@hkhattabii Hmm, do you have a MRE or open-source repo where I can see some code demonstrating the issue? The request body your client code receives can be manipulated with |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The Issue
When I test nextjs api, the body that I send is always undefined if I don't Stringify at test level and parse at api level.
It's working, but when I don't make test, the JSON.parse() stay there and I also have to check wether the request body is stringified or not.
From the test I have to stringify my body, otherwise it is undefined on the api
![client level](https://user-images.githubusercontent.com/54418529/112895136-07ebd400-90dd-11eb-99a3-4ca75f20e083.PNG)
I want to send the request through a client such as postman or web browser I am getting this exception becuase it tries to parse a plain object instead of string.
If I want to use both at test level and client level I have to check if I can parse or not the body
![api level](https://user-images.githubusercontent.com/54418529/112895288-336ebe80-90dd-11eb-903e-4bdb5a98b352.PNG)
The solution
Access to "axios" parameter in the test callback to send body as plain object and avoid to stringify data
Beta Was this translation helpful? Give feedback.
All reactions