demo
demo copied to clipboard
throws error when "id":1 exists in post request body
found some minor cases. though these issues can be ignored by changing my code but still it'll be great if you look into these. specially 'case 2'
-
case 1: post request with body
{"id":1,"name":"raihan"}
throws below mentioned error! of course my id shouldn't be 1 but throwing error from server isn't convenient either. -
case 2: post request with body
{"id":"0","name":"raihan"}
returns id as it is, "0". i think it should return new random id even if my id is string type. -
case 3: post request with body
{"id":0,"name":"raihan"}
works fine though
Error: Insert failed, duplicate id
at Function.insert (/app/node_modules/lodash-id/src/index.js:49:18)
at /app/node_modules/lodash/lodash.js:4374:28
at arrayReduce (/app/node_modules/lodash/lodash.js:683:21)
at baseWrapperValue (/app/node_modules/lodash/lodash.js:4373:14)
at LodashWrapper.wrapperValue (/app/node_modules/lodash/lodash.js:9052:14)
at create (/app/node_modules/json-server/lib/server/router/plural.js:235:48)
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
at next (/app/node_modules/express/lib/router/route.js:137:13)
at next (/app/node_modules/express/lib/router/route.js:131:14)
at Route.dispatch (/app/node_modules/express/lib/router/route.js:112:3)
Yardimci olabilir misiniz