axios introduced, download, use

basic introduction

  • axios is a module package for a call interface
  • Supports get, put, delete, post
  • It does not support jsonp
  • It has been specially good package module call interface, it can be used directly, without encapsulation

download

cnpm install axios -S

  • -D is used only in the development environment
  • -S made not only in the development environment in which to use, but also for use in a production environment

Introduced

import axios from “axios”;

Will automatically go to your node_modules find inside this module

use

  • The first written address
  • The second transmission parameter is an object
  • Params automatically spliced ​​into which data of address a whole
  • .then give you a return also params, you can receive the same then
  • data is to give your response information
    // https://m.lagou.com/listmore.json?pageNo=2&pageSize=15
    axios.get("https://m.lagou.com/listmore.json",{
        params:{
            pageNo:2,
            pageSize:15
        }
    }).then(data=>{})
Published 63 original articles · won praise 6 · views 1195

Guess you like

Origin blog.csdn.net/qq_44163269/article/details/105229135