Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import axios from 'axios'
- import qs from 'qs'
- const axiosInstance = axios.create({
- transformRequest: [function(data) {
- return qs.stringify(data);
- }],
- headers:{
- 'Content-Type': 'application/x-www-form-urlencoded'
- }
- })
- // Send a POST request
- axiosInstance({
- method: 'post',
- url: '/demo/12345',
- data: {
- key1: 'value1',
- key2: 'value2'
- }
- }).then(function(response) {
- console.log(response)
- })
- .catch(function(error) {
- console.log(error)
- })
Add Comment
Please, Sign In to add comment