0

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 ?

Guilherme Cavenaghi
  • 225
  • 1
  • 2
  • 22
  • You should pass headers in the third property https://stackoverflow.com/questions/45578844/how-to-set-header-and-options-in-axios – Maxim Sep 22 '21 at 12:04

1 Answers1

1

add a null as the second parameter

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

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

Iceberg
  • 2,744
  • 19
  • 19