json-server icon indicating copy to clipboard operation
json-server copied to clipboard

POST succeeds only at first try. Further tries fail consistently.

Open accidentalrebel opened this issue 10 years ago • 4 comments

When I do a POST request for the first time, the request pushes through with no problems. But if I do it a second or more times, it consistently fails.

Here is the log of the results:

POST /facebookGroups/ 201 25.756 ms - 28 TypeError: doc.hasOwnProperty is not a function at C:\Users\ARebel\AppData\Roaming\npm\node_modules\json-server\node_modules\underscore-db\src\index.js:36:15 at baseFindIndex (C:\Users\ARebel\AppData\Roaming\npm\node_modules\json-server\node_modules\lodash\lodash.js:823:11) at findIndex (C:\Users\ARebel\AppData\Roaming\npm\node_modules\json-server\node_modules\lodash\lodash.js:7260:14) at Function.find (C:\Users\ARebel\AppData\Roaming\npm\node_modules\json-server\node_modules\lodash\lodash.js:5124:21) at Function.getById (C:\Users\ARebel\AppData\Roaming\npm\node_modules\json-server\node_modules\underscore-db\src\index.js:35:17) at Function.insert (C:\Users\ARebel\AppData\Roaming\npm\node_modules\json-server\node_modules\underscore-db\src\index.js:48:18) at C:\Users\ARebel\AppData\Roaming\npm\node_modules\json-server\node_modules\lodash\lodash.js:4405:28 at arrayReduce (C:\Users\ARebel\AppData\Roaming\npm\node_modules\json-server\node_modules\lodash\lodash.js:704:21) at baseWrapperValue (C:\Users\ARebel\AppData\Roaming\npm\node_modules\json-server\node_modules\lodash\lodash.js:4404:14) at LodashWrapper.wrapperValue (C:\Users\ARebel\AppData\Roaming\npm\node_modules\json-server\node_modules\lodash\lodash.js:9052:14) POST /facebookGroups/ 500 21.789 ms - 1272

The only way for me to send a POST request again is to restart the server. After that, the request succeeds once, then fails again afterwards.

For some reason, it seems to be looking for 'doc.hasOwnProperty" which I have no idea why it only does so the second time.

I'm also not doing anything special, just using Curl in Haxe shown below:

var r2 = haxe.Curl.post("http://localhost:3000/facebookGroups/", "test=1");
trace("POST" + r2);

I'll add that this same thing happens with just plain old Http requests (No cURL).

Hope someone can help me out.

Thanks!

accidentalrebel avatar Nov 19 '16 12:11 accidentalrebel

I'm also running into this issue with the same symptoms (although it's quite possible I'm just doing something wrong).

JustASquid avatar Nov 20 '16 03:11 JustASquid

Try to install previous version, please. npm install [email protected].*

It works.

EternalFire avatar Nov 20 '16 12:11 EternalFire

Hi @accidentalrebel,

Thank you for the report. I've published v0.9.1 with a potential fix, let me know if you still have this issue.

typicode avatar Nov 21 '16 01:11 typicode

This is confirmed fixed on v0.9.1. Thanks a lot, @typicode!

accidentalrebel avatar Nov 21 '16 05:11 accidentalrebel