vue接口中的传参

1.Body参数使用data设置

/**
 * 修改地址
 */
export const updateAddress = (id,newAddress) => {
  return request({
    method: 'patch'
    ,url: `/api/user/address/${id}`
    ,data:newAddress
  })
}

2.Query参数使用params设置

/**
 * 获取文章列表
 */
export const getArticles = params => {
  return request({
    method: 'GET',
    url: '/app/v1_1/articles',
    params
  })
}

3.Headeres参数使用headers设置

/**
 * 获取登录用户信息
 */
export const getCurrentUser = () => {
  return request({
    method: 'GET',
    url: '/app/v1_0/user'
    // headers: {
    //   Authorization: `Bearer ${store.state.user.token}`
    // }
  })
}
posted @ 2021-04-01 16:40  嘿!那个姑娘  阅读(2124)  评论(0编辑  收藏  举报