我如何格式化我的formData对象的结构来匹配后端的期望?
我用formData上传了一张我通过ImagePicker上传的照片。我像这样发送参数:
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
},
});
};
这似乎不起作用,因为我得到了一个非常通用的错误构建‘for nil:NilClass):` NoMethodError (undefined method
。
如果image
参数是图像,而description
参数是字符串,我如何以正确的方式发布我的参数?
谢谢
转载请注明出处:http://www.intsu.net/article/20230514/2304621.html