js-crud-api icon indicating copy to clipboard operation
js-crud-api copied to clipboard

It crashes when connet without tablename

Open maxmenGMK opened this issue 7 years ago • 3 comments

It works, but not as long. When i go to http://192.168.50.44:8000/posts/1, i see correct output: [{"id":1,"title":"testtitle","content":"Testcontent","created":"0000-00-00"}] But when i go to http://192.168.50.44:8000/posts/, i cant see tablenames, i see just [] But when i go to http://192.168.50.44:8000, it crashes: /mysql/lib/protocol/Parser.js:80 throw err; // Rethrow non-MySQL errors ^ TypeError: First argument must be a string or Buffer at ServerResponse.end (_http_outgoing.js:739:13) at Query. (/home/grimakon/apinode/js-crud-api/app.js:90:12) at Query. (/home/grimakon/node_modules/mysql/lib/Connection.js:502:10) at Query._callback (/home/grimakon/node_modules/mysql/lib/Connection.js:468:16) at Query.Sequence.end (/home/grimakon/node_modules/mysql/lib/protocol/sequences/Sequence.js:83:24) at Query.ErrorPacket (/home/grimakon/node_modules/mysql/lib/protocol/sequences/Query.js:90:8) at Protocol._parsePacket (/home/grimakon/node_modules/mysql/lib/protocol/Protocol.js:278:23) at Parser.write (/home/grimakon/node_modules/mysql/lib/protocol/Parser.js:76:12) at Protocol.write (/home/grimakon/node_modules/mysql/lib/protocol/Protocol.js:38:16) at Socket. (/home/grimakon/node_modules/mysql/lib/Connection.js:91:28)

maxmenGMK avatar Sep 14 '18 12:09 maxmenGMK

when i go to http://192.168.50.44:8000/posts/

Can you try: http://192.168.50.44:8000/posts (without trailing slash)?

when you go to http://192.168.50.44:8000

The behavior is undefined for that case.

mevdschee avatar Sep 16 '18 07:09 mevdschee

when i go to http://192.168.50.44:8000/posts/

Can you try: http://192.168.50.44:8000/posts (without trailing slash)?

when you go to http://192.168.50.44:8000

The behavior is undefined for that case.

The result is the same without trailing slash and with trailing slash - it show "[]". When i go to go to http://192.168.50.44:8000 why it is crashes?

maxmenGMK avatar Sep 16 '18 18:09 maxmenGMK

when i go to http://192.168.50.44:8000/posts/

Can you try: http://192.168.50.44:8000/posts (without trailing slash)?

when you go to http://192.168.50.44:8000

The behavior is undefined for that case.

How i can to define the behavior in this case? Can you help me? I am new in coding.

maxmenGMK avatar Sep 17 '18 13:09 maxmenGMK