Javascript-форум (https://javascript.ru/forum/)
-   Общие вопросы Javascript (https://javascript.ru/forum/misc/)
-   -   как отправить post запрос через axios basic auth (https://javascript.ru/forum/misc/76667-kak-otpravit-post-zapros-cherez-axios-basic-auth.html)

AkezhanOb1 01.02.2019 13:15

как отправить post запрос через axios basic auth
 
как отправить post запрос через axios basic auth
и body в x-www-form-urlencoded
const axios = require('axios')
let session_url = '10.50.141.75:8845/auth'

const requestBody = {
  login:    "node js",
  password: "react js"
}

const config = {
  headers: {
    'Content-type': 'application/x-www-form-urlencodeed'
  },
  auth: {
    username: 'testq',
    password: 'test'
  }
}

axios.post(session_url,requestBody, config).then(function(response) {
  console.log('Authenticated')
}).catch(function(error) {
  console.log(error)
})


Часовой пояс GMT +3, время: 21:52.