【发布时间】:2016-07-10 03:59:47
【问题描述】:
我有一个使用 ES6 语法(通过 webpack 使用 json-loader)加载的 JSON 对象(agendaItemsJson)。使用以下内容会出错,因为 fetch 正在尝试解析 URL,而议程项目 Json 是一个对象。
所以我的问题是我怎样才能正确地模仿这一点,以便我能够使用承诺并让议程项目Json 成为我的回应。
'use strict';
import BaseService from './base-service';
import agendaItemsJson from '../json/agenda.json';
class _AgendaService extends BaseService {
getAgenda() {
// TODO: Will use API instead of the JSON here under.
return this.fetch(agendaItemsJson)
.then(response => response);
}
...
【问题讨论】:
标签: javascript json promise webpack fetch-api