Json-server: DELETE doesn't adhere to routes

Created on 5 Apr 2018  路  1Comment  路  Source: typicode/json-server

I have db.json:

{
  "posts": [{ id: 1, title: "My Awesome Post", key: "myawesomepost" }]
}

and routes.json:

{
  "/posts/:key": "/posts?key=:key"
}

GET /posts/myawesomepost

works and I receive the result

DELETE /posts/myawesomepost

returns a 404

Most helpful comment

I realize now that /posts/1 would normally return a single result {...} where /posts?key=myawesomepost is going to return an array of results [{...}].

Is there a simple way to make DELETE work on a non-id property or must one use a middleware?

>All comments

I realize now that /posts/1 would normally return a single result {...} where /posts?key=myawesomepost is going to return an array of results [{...}].

Is there a simple way to make DELETE work on a non-id property or must one use a middleware?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fishenal picture fishenal  路  3Comments

casvil picture casvil  路  4Comments

shikaan picture shikaan  路  3Comments

sboudouk picture sboudouk  路  3Comments

strom picture strom  路  4Comments