首页 > 技术文章 > axios请求中的参数(params)与路径变量

beka 2018-03-07 10:37 原文

1.axios的参数(params)

import axios from 'axios'
export function getDiscList() {
  const url = '/api/getDiscList'
  const data = Object.assign({}, commonParams, {
    plateform: 'yqq',
    hostUin: 0,
    sin: 0,
    ein: 29,
    sortId: 5,
    needNewCode: 0,
    categoryId: 10000000,
    rnd: Math.random(),
    format: 'json'
  })
  return axios.get(url, {
    params: data
  }).then((res) => {
    return Promise.resolve(res.data)
  })
}

在浏览器中的显示方式

2.路径变量(就是请求不同的路径)

浏览器中的显示形式

推荐阅读