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}`
    // }
  })
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM