我正在使用 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
},
});
};
这似乎不起作用,因为我得到了一个非常通用NoMethodError (undefined method
的构建' nil:NilClass):` 错误。
image
鉴于参数是图像并且description
参数是字符串,我如何以正确的方式发布参数?
谢谢