需要向“/...”提交POST请求,并在form-data中包含以下数据:React Native。
firstName: text,
middleName: text,
lastName: text,
email: text,
country: text Alpha-3 country code (e.g. EGY or DEU),
phone: text,
dob: text Date of birth (format YYYY-mm-dd, e.g. 2001-09-25).,
gender: text,
请使用FormData。
import FormData from 'FormData';
var data = new FormData();
data.append("firstname", "abc");
fetch('YOUR_URL', {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'multipart/form-data',
},
body:data,
})
.then((response) => response.json())
.then((responseJson) => {
console.log('response object:',responseJson)
})
.catch((error) => {
console.error(error);
});