【发布时间】:2019-10-09 12:04:20
【问题描述】:
我用 nodejs、express 和 mongodb 创建了一个 API 服务。当我用邮递员甚至在浏览器上测试它时,它工作正常。但是,当我尝试从 Angular 应用程序中执行相同操作时,它会给出一个奇怪的响应。
api服务的角码:
url = 'http://localhost:3000';
getList() {
return this.http.get(this.url);
}
当我在 app.component.ts 中执行以下操作时
console.log(JSON.stringify(this.taskapi.getList()));
这是我在控制台中看到的:
{"_isScalar":false,"source":{"_isScalar":false,"source":{"_isScalar":false,"source":{"_isScalar":true,"value":{"url":"http://localhost:3000","body":null,"reportProgress":false,"withCredentials":false,"responseType":"json","method":"GET","headers":{"normalizedNames":{},"lazyUpdate":null,"headers":{}},"params":{"updates":null,"cloneFrom":null,"encoder":{},"map":null},"urlWithParams":"http://localhost:3000"}},"operator":{"concurrent":1}},"operator":{}},"operator":{}}
我希望得到与邮递员相同的角度响应。我该怎么做?
【问题讨论】:
标签: node.js angular rest api express