The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Lorin S (45) [Avatar] Offline
If implemented as read in the example, line app.component.ts:15 reads:

this.stocks = stocks.json();

This results in the following error in Chrome:

EXCEPTION: stocks.json is not a function

Alternatively, at least in Chrome, the following simple assignment seems to suffice:

this.stocks = stocks;
jeremy.wilken (208) [Avatar] Offline
At what point exactly are you running this, and what code listing is this from?
Lorin S (45) [Avatar] Offline
This was copied and pasted from Listing 2.9... Ran in due course of running through the demo.
jeremy.wilken (208) [Avatar] Offline
I don't see why this is happening, but can you check you have the service correct? Can you check your code against the code in GitHub and see if there is anything different with your version?
476453 (4) [Avatar] Offline
I confirm the error. Currently, I'm at the end of "2.5 Creating your first component". Build fails with: "/stocks/src/app/app.component.ts (15,2smilie: Property 'json' does not exist on type 'StockInterface[]'.". When I remove the .json call, everything builds and works fine.
Geoff Fox (2) [Avatar] Offline
[ 33 KB ]
I have run into the same error! Please provide a working complete solution.

Just downloaded your code solution. It's working and I can now check out my code.
Thank you for providing a working solution. smilie
jeremy.wilken (208) [Avatar] Offline
This looks like an outdated version of the code, which might mean checking you have the latest MEAP or that the final version of the book will be fixed (and match what is on github).
Geoff Fox (2) [Avatar] Offline
Hi Jeremy,
Got it all working and learnt a lot!
Nice book, looking forward to the final version.

Your github code solution helped. smilie

Geoff Fox

PS there are some inconsistencies in the MEAP book:

ng generate component components/summary
gives a selector <app-summary></app-summary>
the book shows <summary></summary>

ng generate component components/summary --prefix=false

or change the .angular-cli.json from the default prefix "app"

would fix it.
431294 (1) [Avatar] Offline
app.component.ts fails to run - book still inconsistent
As far as I see the book version is still outdated. The github code of app.component.ts does not contain references to json, but Chapter 2 (both in the latest version I have as well as in the live book, listing 2.9) still refer to json.

Not using the github but trying to start from ng new all the way as explained in chapter 2 does not work at the moment.
welkie (26) [Avatar] Offline
Can confirm that I experienced this while reading Chapter 2 of V12 today. Removing the ".json()" worked. Seems the new HttpClient returns it as JSON automatically.
Julitogtu (1) [Avatar] Offline
Yes, removing
the code works, also, look in github ( the changes of the component and confirm that the before version of the code does not use the
jeremy.wilken (208) [Avatar] Offline
Getting this fixed for good in the proofs, thanks for pointing it out.