问题描述
我为 GET
、PUT
、POST
、DELETE
创建了 API。
这些 API 在 postman 上正确运行,并且根据 API 类型(获取、放置、发布、删除)相应的更改反映在数据库中(使用的 MongoDb 数据库)。
但是当我尝试在 web 组件项目中使用相同的 API 时,我收到了错误,因为承诺被拒绝。
这是我的代码:
async getCandidateList() {
const res: Response = await ApiService.getList();
this.candidateList = await res.json();
this.requestUpdate();
}
getList(): any {
return $http.get('http://localhost:3000/candidate');
}
但是,它抛出以下错误:
Promise {<pending>}
__proto__: Promise[[PromiseState]]: "rejected"
[[PromiseResult]]: TypeError: Failed to fetch
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)