Skip to content

Latest commit

 

History

History
55 lines (44 loc) · 1.09 KB

axios.md

File metadata and controls

55 lines (44 loc) · 1.09 KB
title description created updated
axios (Javascript Library)
Axios is promise based HTTP client for both clientside and server side
2019-06-21
2019-06-21

Axios is promise based HTTP client for both clientside and server side

Installation

npm install axios

Example GET request

const axios = require('axios');

axios.get('https://httpbin.org/get')
        .then(function (response) {
            // handle success
            console.log(response);
        })
        .catch(function (error) {
            // handle error
            console.log(error);
        })
        .finally(function () {
            // always executed
        });

Example GET request (using async/ await)

const response = await axios.get('https://httpbin.org/get');
console.log(response);

Example POST request

axios.post('https://httpbin.org/post', {
            foo: "bar"
        })
        .then(function (response) {
            console.log(response);
        })
        .catch(function (error) {
            console.log(error);
        });