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