axios sentry code example
Example 1: axios post
axios.post('/user', {
firstName: 'Fred',
lastName: 'Flintstone'
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
Example 2: axios instance
const getUser = axios.create({
baseURL: 'https://randomuser.me/api/',
timeout: 1000,
headers: {'X-Custom-Header': 'foobar'}
});
getUser().then(response => console.log(response))
Example 3: axios put request
const res = await axios.put('https://httpbin.org/put', { hello: 'world' });
res.data.headers['Content-Type'];
Example 4: axios post
axios({
method: 'post',
url: '/login',
data: {
firstName: 'Finn',
lastName: 'Williams'
}
});