Axios:如何将参数作为查询字符串发送

时间:2018-11-06 14:00:32

标签: httprequest axios put http-request-parameters

这是我代码的基础

    const params = {
            contractId: data.contractId,
            notificationEmail: data.notificationEmail,
            userNumber: data.userNumber
    }

    axios.put(update_user_url, params, {
            headers: {
                Authorization: `Bearer ${authToken}`
            }
        }).then(blablabla....)

但是,Axios在正文中发送contractId,email和User字段,而不是作为查询字符串。如何使其发送查询字符串?

1 个答案:

答案 0 :(得分:1)

axios.put(
   `${base_url}/user`,
     null,
     {
        params: params,
        headers: {
          Authorization: token
        }
     }
);

检查documentation