What is the correct way to do this FETCH to send an image?

0

fetch ('http://localhost:3000/api/demos/create/${this.state.name}/${this.state.img}', {
    method: 'POST',
  })

The problem with this method is that it sends me this request and it's wrong

http://localhost:3000/api/demos/create/dasda/C:/fakepath/Screen%20Shot%202016-12-13%20at%205.43.40%20PM.png

For example, from the postman, I send it as a body and it works, but not here, any ideas?

    
asked by Santiago D'Antuoni 19.01.2017 в 19:14
source

1 answer

0

From what I read in your comments: The error I see is that even if the application is local the server is localhost (which is disguised as an external server), to think of being local you have to take the image of a server path, so you get an error when you add the image .

There is no path on the server that is C:\fakepath .

If you want to show the image you have to have the image inside your project / server and put the path of this in the server. so that it works (assuming you have the page in root) it should be something like images/myimage.png

Add the image to the project and use it from the server path to appear.

I hope it works for you

    
answered by 19.01.2017 в 21:35