“Axios Post” Código de respuesta

Cómo enviar encabezado en 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

axios

npm i axios
Hurt Herring

Axios Post

const axios = require('axios');
axios.post('/user', {
    firstName: 'Fred',
    lastName: 'Flintstone'
  })
  .then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.log(error);
  });
Gleaming Goat

Axios Post

axios.post('https:sample-endpoint.com/user', {
    Name: 'Fred',
    Age: '23'
  })
  .then(function (response) {
    console.log(response);
  })
Kind Kitten

Axios Post

axios.post('/user', {
    firstName: 'Fred',
    lastName: 'Flintstone'
  })
  .then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.log(error);
  });
  
 #Performing multiple concurrent requests
  function getUserAccount() {
  return axios.get('/user/12345');
}

function getUserPermissions() {
  return axios.get('/user/12345/permissions');
}

Promise.all([getUserAccount(), getUserPermissions()])
  .then(function (results) {
    const acct = results[0];
    const perm = results[1];
  });
Irfan

Axios Post

try {
			const response = await axios.post('https://movie-app-3073.herokuapp.com/login/', {
				Username: username,
				Password: password
			});
			const data = response.data;
			props.onLoggedIn(data);	
		} catch (error) {
			console.log('This user cannot be found');
		}
Quaint Quelea

Respuestas similares a “Axios Post”

Preguntas similares a “Axios Post”

Más respuestas relacionadas con “Axios Post” en JavaScript

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código