React native 使用axios和reactjs调用asp.net api localhost
我已经花了好几个小时了。我决定把问题贴出来 我有一个由asp.net在解决方案上开发的APIReact native 使用axios和reactjs调用asp.net api localhost,react-native,asp.net-web-api,axios,React Native,Asp.net Web Api,Axios,我已经花了好几个小时了。我决定把问题贴出来 我有一个由asp.net在解决方案上开发的API public class ApiOpsController : ApiController { private static readonly IOpsRepository OpsRepository = new OpsRepository(); public IEnumerable<Opdt> Get(string styleCode, strin
public class ApiOpsController : ApiController
{
private static readonly IOpsRepository OpsRepository = new OpsRepository();
public IEnumerable<Opdt> Get(string styleCode, string styleSize, string styleColor, string revNo, string opRevNo,
string edition, string languageId)
{
return OpsRepository.Get(styleCode, styleSize, styleColor, revNo, opRevNo, edition, languageId);
}
}
这使我犯了这个错误
注意:我试图放置:
“代理”:http://localhost:63762“
到package.json,仍然不工作。在不等待的情况下调用axios。因为您的代码(“await axios(config).catch(error=>console.log(error)))应用于catch回调。不等待尝试不等待调用axios。因为您的代码(“await axios(config).catch(error=>console.log(error)))应用于catch回调。未雨绸缪
const config = {
method: "get",
url: "http://localhost:63762/api/ApiOps?styleCode=UAR0348&styleSize=RGL&styleColor=001&revNo=002&opRevNo=001&edition=MES&languageId=en",
headers: {
"Content-Type": "application/json; charset=utf-8"
}
};
let res = await axios(config).catch(error => console.log(error));;