【发布时间】:2018-09-27 07:40:22
【问题描述】:
我有一个 asp.net web api:
public virtual async Task<Customer> AddCustomer(Customer customer, CancellationToken cancellation)
{
Customer existingCustomer = (await Repository.GetAllAsync(cancellation)).Where(cu => cu.NationalCode == customer.NationalCode).FirstOrDefault();
if (existingCustomer != null)
throw new Exception("you registered before. please login");
return await Repository.AddAsync(customer, cancellation);
}
我可以通过这段代码在本机反应中发布到这个 api:
var url = '/Sanaap.Api/odata/Sanaap/Customers/Sanaap.LoginCustomer';
fetch(url, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
FirstName: '',
LastName: '',
NationalCode: this.state.ncode.toString(),
Mobile: this.state.mobile.toString(),
})
}).then((response) => {
if (response.status == 500) {
alert('500');
Toast.show({
text: "not found",
position: 'bottom', duration: 5000, type: 'danger'
});
return;
}
if (response.status == 200) {
alert('200');
this.props.navigation.navigate("EvalReq");
}
});
什么是 android studio 中的相等代码而不是获取发布客户并获取插入的客户 ID?
【问题讨论】:
标签: android-studio post react-native asp.net-web-api fetch