Ivo Ivanov
Ivo Ivanov

Reputation: 61

Axios: How to send Params as Query String

This is the base of my code

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

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

However Axios sends the contractId, email and User fields in body, not as a Query string. How do I make it send a query string?

Upvotes: 1

Views: 3970

Answers (1)

itidsu
itidsu

Reputation: 54

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

Check the documentation.

Upvotes: 1

Related Questions