Home > Back-end >  Reactjs : Header in axios [duplicate]
Reactjs : Header in axios [duplicate]

Time:09-22

Im trying to send an header with a email to my API , but my API always receive a body{headers:{email:xxx

my code in the client is like this :

export const envmailesqueci = async (
  credentials,
  setFieldError,
  setSubmitting
) => {
    await axios
      .post("http://localhost:3003/users/forgotpassword",{headers:
        {email:credentials.email}
      }  
).then((response) => {
        setSubmitting(false);

How can I change it to send a header instead of a header inside of the body ?

CodePudding user response:

add a null as the second parameter

await axios
      .post(url, null, {headers:
        {email:credentials.email}
      }  

axios#post(url[, data[, config]])

  • Related