selvi jp

selvi jp

  • NA
  • 323
  • 79k

fetching post in react js

Oct 12 2021 8:59 AM

If i post formdata i am facing this error.× Unhandled Rejection (TypeError): Failed to fetch

handleSubmit(event) {
    event.preventDefault();
    const data = new FormData(event.target);
    let user = JSON.parse(localStorage.getItem('user'));
    const accessToken=user;
    fetch(url, {
      method: 'POST',
      headers:{
          Accept: 'application/json',             
          Authorization: "Bearer " +accessToken 
      },
      body: data,
    });
  }

 


Answers (2)