“cara mengirim header di axios” Kode Jawaban

header di Axios

axios.post('url', {"body":data}, {
    headers: {
    'Content-Type': 'application/json'
    }
  }
)
Salo Hopeless

cara mengirim header di axios

const username = ''
const password = ''

const token = Buffer.from(`${username}:${password}`, 'utf8').toString('base64')

const url = 'https://...'

axios.post(url, {
  headers: {
    'Authorization': `Basic ${token}`
  }
})
Creepy Copperhead

Posting Axios dengan header

// Send a POST request
axios({
  method: 'post',
  url: '/user/12345',
  data: {
    firstName: 'Fred',
    lastName: 'Flintstone'
  },
  headers: {'Authorization': 'Bearer ...'}
});
Victor Grk

Axios.Post Permintaan dengan header khusus

var postData = {
  email: "[email protected]",
  password: "password"
};

let axiosConfig = {
  headers: {
      'Content-Type': 'application/json;charset=UTF-8',
      "Access-Control-Allow-Origin": "*",
  }
};

axios.post('http://<host>:<port>/<path>', postData, axiosConfig)
.then((res) => {
  console.log("RESPONSE RECEIVED: ", res);
})
.catch((err) => {
  console.log("AXIOS ERROR: ", err);
})
Lazy Llama

Axios dapatkan dengan header

let auth = ``; //auth key
let url = ``; //api url

const axios = require(`axios`);
axios({
    method: 'get',
    url: url,
    headers: {
        "Authorization": auth
    },
}).then(function (res) {
    console.log(res.data)
});
Luna

Contoh Header Axios.Post

axios.post(
'https://example.com/postSomething', 
{ // this is the body
 email: varEmail, 
 password: varPassword
},
{
  headers: {
    Authorization: 'Bearer ' + varToken
  }
})
JoseHdez

Jawaban yang mirip dengan “cara mengirim header di axios”

Pertanyaan yang mirip dengan “cara mengirim header di axios”

Lebih banyak jawaban terkait untuk “cara mengirim header di axios” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya