226753 (6) [Avatar] Offline
#1
Hi,

Had bought the MEAP long back, but didn't get a chance to go through it earlier and started only yesterday. Chapter 1 was interesting read, and tried to run the APIs directly on the browser and curl. The GETs are working on both, but the POST and PUT are giving errors (sorry, I am not able to update or my favorite toppings smilie). The error is as below:
curl -H "Content-Type: application/json" -X POST -d '{"title":"Black Olives"}' http://irresistibleapis.com/api/v1.0/toppings

TypeError: Cannot call method 'hasOwnProperty' of undefined<br>    at app.delete.res.statusCode (/home/synedra/irresistible/webapp/toppings.js:46:16)<br>    at Layer.handle [as handle_request] (/home/synedra/irresistible/webapp/node_modules/express/lib/router/layer.js:95:5)<br>    at next (/home/synedra/irresistible/webapp/node_modules/express/lib/router/route.js:131:13)<br>    at Route.dispatch (/home/synedra/irresistible/webapp/node_modules/express/lib/router/route.js:112:3)<br>    at Layer.handle [as handle_request] (/home/synedra/irresistible/webapp/node_modules/express/lib/router/layer.js:95:5)<br>    at /home/synedra/irresistible/webapp/node_modules/express/lib/router/index.js:277:22<br>    at Function.process_params (/home/synedra/irresistible/webapp/node_modules/express/lib/router/index.js:330:12)<br>    at next (/home/synedra/irresistible/webapp/node_modules/express/lib/router/index.js:271:10)<br>    at serveStatic (/home/synedra/irresistible/webapp/node_modules/express/node_modules/serve-static/index.js:74:16)<br>    at Layer.handle [as handle_request] (/home/synedra/irresistible/webapp/node_modules/express/lib/router/layer.js:95:5)

The PUT shows similar error.
Kirsten Hunter (13) [Avatar] Offline
#2
I'll take a look right now! Thanks for the heads up, I'm going through an editing pass so I'll get it fixed up and get the updated version up there.

Thanks!
Kirsten
Kirsten Hunter (13) [Avatar] Offline
#3
This was due to a change in how express handled JSON. It's fixed now on the site - I'll check the docker install as well.
226753 (6) [Avatar] Offline
#4
Thanks. Now my favorite toppings is on the Pizza smilie

Since boot2docker is being deprecated on windows, I setup docker on linux. But I am unable to proceed further as I am unable to pull the container, see below:
sudo docker run -i -t -p 80:5000 synedra/irresistible /bin/bash

Unable to find image 'synedra/irresistible:latest' locally
Pulling repository docker.io/synedra/irresistible
Error while pulling image: Get https://index.docker.io/v1/repositories/synedra/irresistible/images: dial tcp: lookup index.docker.io: no such host


Regards,
CElliott (11) [Avatar] Offline
#5
It would be better if at least one line in the Curl examples in section 2.4.2 could be made to work.