我有一个照片应用程序(React Native),它试图向 nodejs express 端点发出 POST 请求,其中包含照片和一些元数据。节点应用程序将照片上传到 s3。
使用 multer,照片 + s3 位运行良好,但我似乎无法访问元数据。它遇到了空。
客户:React Native
var formData = new FormData();
formData.append('photo', {
uri: this.state.photo.uri,
name: 'image.jpg',
type: 'image/jpeg',
});
formData.append('meta', {
title: "the best title",
lat: this.state.lat,
long: this.state.long
});
const config = {
method: 'POST',
body: formData,
headers: {
'Accept': 'application/json',
}
}
console.log(config) // I see both photo and meta in the formData
fetch("http://localhost:5001/upload", config)
.then((responseData) => {
console.log('awesome, we did it');
})
.catch(err => {
console.log(err);
}); …Run Code Online (Sandbox Code Playgroud)