Corda /upload/attachment using fetch api gets correct response in network but throws error

Viewed 72

I'm trying to attach a document to my node. I have the following code in React.

const url = `http://localhost:10015/upload/attachment`;
const formData = new FormData();
formData.append('file',file); // from file select
let result = await fetch(url, {
  method: 'post',
  body: formData
});

When I view the network logs, it looks like there isn't an issueenter image description here

And the response is the hash of the attachment.

When I view the logs, I have this error:

enter image description here

Could anyone help me out with this?

1 Answers

It looks like your browser is blocking the request based on its Cross-Origin Resource Sharing (CORS) policy. Try disabling CORS in the browser or making the same request using a tool like Postman and seeing whether the request is a success.

Related