Skip to content

Instantly share code, notes, and snippets.

@clarencetw
Created November 5, 2020 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clarencetw/3a2123923b7c33032c9fc4f3366033f2 to your computer and use it in GitHub Desktop.
Save clarencetw/3a2123923b7c33032c9fc4f3366033f2 to your computer and use it in GitHub Desktop.
Axios post x-www-form-urlencoded
const axios = require('axios')
const qs = require('querystring')
const requestBody = {
name: 'name',
}
const config = {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}
axios.post(url, qs.stringify(requestBody), config)
.then((result) => {
// Do somthing
})
.catch((err) => {
// Do somthing
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment