I try to post via node-fetch to golang API files with some structure, I can make it from postman, but no way from NodeJS
Hi there. im at dead end, i had tried everything...
I need make a request to golang api, i can create it in Postman: its look like this: postman request
And I need to repeat it in NodeJs, But i always getted bad request from API
here is my code on Node
let formData = new FormData()
formData.append('postUUID', postUuid)
json.data.uploadIds.map((upl, index) => {
let file = data.files.find(el => el == upl.filename)
formData.append(upl.uuid, fs.readFileSync(file));
})
let headers = new Headers()
headers.append('Authorization', 'Bearer '+token)
headers.append("Accept", "application/json");
fetch(API+'/posts/uploadMediaFiles', {
method: 'POST',
headers,
body: formData
})
Difference with postman generated code only in formdata.append("f2b07a43-f79f-4033-ab2d-bb3176934679", fileInput.files[0], "/file_0.jpg"); and i do instead of formData.append(upl.uuid, fs.readFileSync(file));