Skip to content

todoList example not working as expected: ?missing route GET /todo-list/{id}/todos Β #2050

@cloudwheels

Description

@cloudwheels

Description / Steps to reproduce / Feature proposal

  • Follow todoList tutorial from working version of todos example
  • follow steps to test new api behaviour

Current Behavior

  • POST /todo-lists with a body of { "title": "grocery list" }

curl -X POST "https://lb4.eu-gb.mybluemix.net/todo-lists" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"title\":\"grocery list\"}"

200 OK
{
  "id": "f802a73624452ae109f5f67921f029b1",
  "title": "grocery list"
}
  • POST /todo-lists/{id}/todos using the ID you got back from the previous POST request and a body for a todo. Notice that response body you get back contains property todoListId with the ID from before.

curl -X POST "https://lb4.eu-gb.mybluemix.net/todo-lists/f802a73624452ae109f5f67921f029b1/todos" -H "accept: */*" -H "Content-Type: application/json" -d "{\"title\":\"my Todo\",\"desc\":\"todo added via todo-lists/f802a73624452ae109f5f67921f029b1/todos\"}"

200 OK
{
  "id": "89457642c79b2bd07c0d09c5e347d1d3",
  "title": "my Todo",
  "desc": "todo added via todo-lists/f802a73624452ae109f5f67921f029b1/todos",
  "todoListId": "f802a73624452ae109f5f67921f029b1"
}

Expected Behavior

As expected until this point.

  • GET /todos/{id}/todos and see if you get the todo you created from before.

  • GET /todos/{id}/todos is not a route!
    Should there be a route GET /**todo-list**/{id}/todos ??

  • GET /todos/{id} returns the todo:
    curl -X GET "https://lb4.eu-gb.mybluemix.net/todos/89457642c79b2bd07c0d09c5e347d1d3" -H "accept: application/json"

200 - OK
{
  "id": "89457642c79b2bd07c0d09c5e347d1d3",
  "title": "my Todo",
  "desc": "todo added via todo-lists/f802a73624452ae109f5f67921f029b1/todos",
  "todoListId": "f802a73624452ae109f5f67921f029b1"
}
  • The todoList Model is not updated with the todo (or reference to it) on its list:
    GET todo-lists/{id}
    curl -X GET "https://lb4.eu-gb.mybluemix.net/todo-lists/f802a73624452ae109f5f67921f029b1" -H "accept: application/json"
200 -OK
{
  "id": "f802a73624452ae109f5f67921f029b1",
  "title": "grocery list"
}

Expected: (minimum of)

{
  "id": "f802a73624452ae109f5f67921f029b1",
  "title": "grocery list",
 "todos": [
    {
      "id": "89457642c79b2bd07c0d09c5e347d1d3"
    }
  ]
}

@dhmlau FYI

Metadata

Metadata

Assignees

Labels

DocsExamplesRESTIssues related to @loopback/rest package and REST transport in generalgood first issue

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions