Skip to content

Instantly share code, notes, and snippets.

@akexorcist
Last active September 13, 2024 19:03
Show Gist options
  • Select an option

  • Save akexorcist/ea93ee47d39cf94e77802bc39c46589b to your computer and use it in GitHub Desktop.

Select an option

Save akexorcist/ea93ee47d39cf94e77802bc39c46589b to your computer and use it in GitHub Desktop.
Axios post method requesting with x-www-form-urlencoded content type. See https://axios-http.com/docs/urlencoded
const axios = require('axios')
/* ... */
const params = new URLSearchParams()
params.append('name', 'Akexorcist')
params.append('age', '28')
params.append('position', 'Android Developer')
params.append('description', 'birthdate=25-12-1989&favourite=coding%20coding%20and%20coding&company=Nextzy%20Technologies&website=http://www.akexorcist.com/')
params.append('awesome', true)
const config = {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}
axios.post(url, params, config)
.then((result) => {
// Do somthing
})
.catch((err) => {
// Do somthing
})
@mulhoon

mulhoon commented Jan 18, 2022

Copy link
Copy Markdown

👍

@Gaeta

Gaeta commented Jan 29, 2022

Copy link
Copy Markdown

👍

@duzzisantos

Copy link
Copy Markdown

import qs from 'qs
and qs.stringify() worked like magic. Thanks for redirecting me to the github page of axios promises. Thanks!

@amirgholikhani

Copy link
Copy Markdown

@vassiliy278

Copy link
Copy Markdown

Thank's a lot dude! I've beated the issue for 5 hours and finally solved!

@neogeogre

Copy link
Copy Markdown

Nice !

@abelfriasdiaz

Copy link
Copy Markdown

Thank you soooo much for this!

@xchopox

xchopox commented Apr 24, 2022

Copy link
Copy Markdown

Thank you so much for this solution 🙌 🥺

@ugurcanerdogan

Copy link
Copy Markdown

Very much thanks !

@NashChenEzTable

Copy link
Copy Markdown

nice

ghost commented Jun 21, 2022

Copy link
Copy Markdown

Thanks!

@rodrigoaveloes

Copy link
Copy Markdown

nice bro! thi

import qs from 'qs and qs.stringify() worked like magic. Thanks for redirecting me to the github page of axios promises. Thanks!

Exactly what I did, I found it more easier

@vinayaksapa

Copy link
Copy Markdown

Thanks ! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment