Getting JSON for Angular 2 from HTTP remote server fails, but succeeds localy

前端 未结 1 333
自闭症患者
自闭症患者 2020-12-21 16:03

I\'m trying to read a JSON file using htttp.get in Angular2.

When I use a file stored localy on my project, it works OK.

Bu

相关标签:
1条回答
  • 2020-12-21 16:41

    Not found collection error suggest that you have used angular-in-memory-web-api before. You need to remove everything related to that from your project, that would equal removing from imports in your NgModule the equal of the following:

    InMemoryWebApiModule.forRoot(InMemoryDataService)
    

    so that you are able to use external api and db.

    Otherwise your code shouldn't change, but if you want, following this tutorial should help you.

    0 讨论(0)
提交回复
热议问题