how to post via axios an element with variable characters code example
Example 1: axios post urlencoded
const axios = require('axios')
const qs = require('querystring')
...
const requestBody = {
name: 'Akexorcist',
age: '28',
position: 'Android Developer',
description: 'birthdate=25-12-1989&favourite=coding%20coding%20and%20coding&company=Nextzy%20Technologies&website=http://www.akexorcist.com/',
awesome: true
}
const config = {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}
axios.post(url, qs.stringify(requestBody), config)
.then((result) => {
})
.catch((err) => {
})
Example 2: axios response return html not json data
if (process.env.NODE_ENV === 'production') {
app.use(express.static(resolve(process.cwd(), 'client/build')))
app.get('*', (req, res) => {
res.sendFile(resolve(process.cwd(), 'client/build/index.html'))
})
}