项目作者: hellosophiee

项目描述 :
Axios tutorial shows how to generate requests in JavaScript using Axios client library.
高级语言: JavaScript
项目地址: git://github.com/hellosophiee/axios.git
创建时间: 2020-07-09T11:03:55Z
项目社区:https://github.com/hellosophiee/axios

开源协议:

下载


Axios tutorial

Axios tutorial shows how to generate requests in JavaScript using Axios client library.

Axios

Axios is a promise based HTTP client for the browser and Node.js. Axios makes it easy to send asynchronous HTTP requests to REST endpoints and perform CRUD operations. It can be used in plain JavaScript or with a library such as Vue or React.

In this tutorial we work with Axios in a Node.js application.

Setting up Axios

First, we install Axios.

  1. $ node -v
  2. v14.5.0

We use Node.js version 14.5.

  1. $ npm init -y

We initiate a new Node.js application.

  1. $ npm i axios

We install Axios with npm i axios command.

Axios Response object

When we send a request to a server, it returns a response. The Axios response object consists of:

  • data - the payload returned from the server
  • status - the HTTP code returned from the server
  • statusText - the HTTP status message returned by the server
  • headers - headers sent by server
  • config - the original request configuration
  • request - the request object