我在下面有一点 javascript。在我们的 ES6 项目中使用 async/await。我注意到现在突然之间没有 404 响应代码。事实上 .json() 也抛出了一个控制台错误,但仍然没有抓住问题。我希望尝试中的任何错误都会立即抛出并转到代码的 catch 块。
async getDash(projectId, projectUserId) {
try {
const events = (await this.apiHttp
.fetch(`${projectId}/users/${projectUserId}/participant-event-dash`)).json();
return events;
} catch (e) {
// fail back to local (dev testing)
return (await this.http
.fetch(`${this.appConfig.url}dist/api/query/json/partic-event-dash.json`)).json();
}
}