axios 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.
Axios是用于浏览器和Node.js的基于Promise的HTTP客户端。 通过Axios,可以轻松地向REST端点发送异步HTTP请求并执行CRUD操作。 它可以在普通JavaScript中使用,也可以与Vue或React之类的库一起使用。
In this guide, I will teach you how to understand the fundamentals of Axios.
在本指南中,我将教您如何理解Axios的基础知识。
入门 (Getting Started)
Before starting using Axios, you need to install Node JS and NPM to install Axios. Once you have installed all requirements, we are going to install Axios.
在开始使用Axios之前,您需要安装Node JS和NPM才能安装Axios。 安装完所有要求后,我们将安装Axios。
First, create a new NPM project:
首先,创建一个新的NPM项目:
$ npm init -y
Once you have initialized a new NPM project, you can install Axios.
初始化新的NPM项目后,即可安装Axios。
Install Axios
安装Axios
npm install axios
You can also use Yarn to install Axios if you prefer that:
如果您愿意,也可以使用Yarn安装Axios:
yarn add axios
A