I am using formData to POST an image I uploaded via ImagePicker. I am sending the parameters like so:
let formData = new FormData();
formData.append('image', { uri: localUri, name: filename, type });
formData.append('description', 'this is the decription');
return await fetch('https://prana-app.herokuapp.com/v1/visions/', {
method: 'POST',
body: formData,
header: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-User-Email': this.state.email,
'X-User-Token': this.state.accessToken
},
});
};
This doesn't seem to work, as I am getting a very generic NoMethodError (undefined method
build' for nil:NilClass):` error.
How can I POST my parameters in the correct way given that the image
parameter is an image and the description
parameter is a string?
Thanks