mamund / Building-Hypermedia-APIs

Source code for the O'Reilly book of the same name
http://amundsen.com/hypermedia/
77 stars 37 forks source link

NodeJs Collection code JSON response error #11

Open paboulos opened 9 years ago

paboulos commented 9 years ago

A GET request to the express URL http://localhost:3000/collection/tasks/ receives a SyntaxError: JSON.parse: unexpected non-whitespace in the application/json response body.

"items" : [

  {
    "href" : "http://localhost:3000/collection/tasks/task3",
    "data" : [
      {"name" : "description", "value" : "This is my third task.", "prompt" : "Description"},
      {"name" : "completed", "value" : false, "prompt" : "Completed"},
      {"name" : "dateDue", "value" : "2011-11-30", "prompt" : "Date Due"}      
    ]
  }
  ,

  {
    "href" : "http://localhost:3000/collection/tasks/task2",
    "data" : [
      {"name" : "description", "value" : "This is my second task.", "prompt" : "Description"},
      {"name" : "completed", "value" : true, "prompt" : "Completed"},
      {"name" : "dateDue", "value" : "2011-12-29", "prompt" : "Date Due"}      
    ]
  }
  ,

  {
    "href" : "http://localhost:3000/collection/tasks/task1",
    "data" : [
      {"name" : "description", "value" : "This is my first task.", "prompt" : "Description"},
      {"name" : "completed", "value" : false, "prompt" : "Completed"},
      {"name" : "dateDue", "value" : "2011-12-31", "prompt" : "Date Due"}      
    ]
  }

]
paboulos commented 9 years ago

The files app.js is pointing to the wrong template and layout.ejs needs to include the correct partial.