“Permintaan Pos Axios” Kode Jawaban

AXIOS CDN

<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
Funny Frog

header di Axios

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

Posting Axios dengan header

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

Posting Axios

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

cara menggunakan Axios Get

const req = async () => {
  const response = await axios.get('https://dog.ceo/api/breeds/list/all')
  console.log(response)
}
req() // Calling this will make a get request and log the response.
Grotesque Gaur

Permintaan Pos Axios

const createPostRequest = async () => {
	try{
		const { data } = await axios.post(url, body_data, {
		   headers: {
	    	 'Authorization': `Basic ${token}`
		   },
		})
    
	    console.log(data)
	} catch (error) {
		console.log(error)
	}
}

createPostRequest();
Inquisitive Iguana

Jawaban yang mirip dengan “Permintaan Pos Axios”

Pertanyaan yang mirip dengan “Permintaan Pos Axios”

Lebih banyak jawaban terkait untuk “Permintaan Pos Axios” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya