【发布时间】:2019-09-14 18:14:18
【问题描述】:
我正在尝试使用 aurelia-fetch-client 从外部 JSON 文件中获取数据,但它给出了 404 not found 错误。
我已尝试实施官方文档建议的基本设置。
这是我的代码:
import {HttpClient } from 'aurelia-fetch-client';
let httpClient = new HttpClient();
export class ChangeRequest {
constructor(){
httpClient.fetch('sample.json')
.then(response => response.json())
.then(res => {
console.log(res);
}
}
}
我应该得到 JSON 数据的结果,但我收到以下错误:
这是我使用aurelia-cli创建的文件夹结构
如您所见,sample.json 位于 src 文件夹中,我尝试将其放入 src/Assets 文件夹中,但结果相同。
【问题讨论】:
标签: aurelia