How use 'application/x-www-form-urlencoded' in Get method with axios

when I use Postman tool to test my request GET, everything is working when I check 'application/x-www-form-urlencoded' in Body settings

But when I use Axios, I feel that my settings are not taken into account! Because I have the following error "the user does not exist"

axios({ method: 'get', url: `${baseURL}/api/collect/getSante`, params: { lastName: 'value' }, headers: { 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' } }) 

I expect json response but I have "the user does not exist"

1

1 Answer

Maybe you could try using URLSearchParams for application/x-www-form-urlencoded. F.e. :

const params = new URLSearchParams(); params.append('param1', 'value1'); params.append('param2', 'value2'); axios.post('/foo', params); 

Source:

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like