Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular tutorial, InMemoryWebApiModule throwing 500 internal server error with angular-in-memory-web-api 0.6.0

InMemoryWebApiModule is working with downloaded source code where "angular-in-memory-web-api": "~0.5.0" But not with"angular-in-memory-web-api": "^0.6.0" I have followed the tutorial,to install angular-in-memory-web-api :

npm install angular-in-memory-web-api --save

And it installed "angular-in-memory-web-api": "^0.6.0"

Error Message:

webpack-internal:///./src/app/hero.service.ts:87 Object body: error: "Object(...) is not a function" __proto__: Object headers: HttpHeaders lazyInit: ƒ () lazyUpdate: null normalizedNames: Map(0) {} __proto__: Object status: 500statusText: "Internal Server Error" url: "api/heroes" __proto__: Object (anonymous) @ webpack-internal:///./src/app/hero.service.ts:87

like image 450
Drisal Avatar asked Mar 23 '18 21:03

Drisal


2 Answers

It was indeed an issue with the version of angular-in-memory-web-api.

I force installed v0.5.4 as zyzof suggested and it fixed it immediately! Thanks

npm install [email protected] --save
like image 28
Totize Avatar answered Nov 08 '22 12:11

Totize


Looks like the 0.6.0 release of angular-in-memory-web-api has some breaking changes, which are likely out of sync with the versions of angular and rxjs that the tutorial has had you install.

Simplest fix is just to install the 0.5.4 version of angular-in-memory-web-api:

npm install [email protected] --save

like image 194
zyzof Avatar answered Nov 08 '22 11:11

zyzof