Skip to content
This repository has been archived by the owner on Oct 11, 2022. It is now read-only.

Methods with primitive args #131

Open
Nidroide opened this issue Jan 5, 2017 · 0 comments
Open

Methods with primitive args #131

Nidroide opened this issue Jan 5, 2017 · 0 comments

Comments

@Nidroide
Copy link

Nidroide commented Jan 5, 2017

server/main.js:

Meteor.methods({hello:(x)=>x});

shell:

curl -X POST http://localhost:3000/methods/hello -H "Content-type: application/json" -H "Accept: application/json" -d '"hello"'

server log:

W20170105-11:50:02.743(1)? (STDERR) Error: invalid json
W20170105-11:50:02.743(1)? (STDERR)     at parse (/home/nidroide/.meteor/packages/simple_json-routes/.2.1.0.9jn1dn++os+web.browser+web.cordova/npm/node_modules/connect/node_modules/body-parser/lib/types/json.js:83:15)
W20170105-11:50:02.743(1)? (STDERR)     at /home/nidroide/.meteor/packages/simple_json-routes/.2.1.0.9jn1dn++os+web.browser+web.cordova/npm/node_modules/connect/node_modules/body-parser/lib/read.js:108:18
W20170105-11:50:02.744(1)? (STDERR)     at invokeCallback (/home/nidroide/.meteor/packages/simple_json-routes/.2.1.0.9jn1dn++os+web.browser+web.cordova/npm/node_modules/connect/node_modules/body-parser/node_modules/raw-body/index.js:262:16)
W20170105-11:50:02.744(1)? (STDERR)     at done (/home/nidroide/.meteor/packages/simple_json-routes/.2.1.0.9jn1dn++os+web.browser+web.cordova/npm/node_modules/connect/node_modules/body-parser/node_modules/raw-body/index.js:251:7)
W20170105-11:50:02.744(1)? (STDERR)     at IncomingMessage.onEnd (/home/nidroide/.meteor/packages/simple_json-routes/.2.1.0.9jn1dn++os+web.browser+web.cordova/npm/node_modules/connect/node_modules/body-parser/node_modules/raw-body/index.js:308:7)
[...]

So how to call methods with primitive arguments? using method options and urlencoded arguments works but seems to be wasteful...anything am I missing?

note: per rfc 7159 "A JSON text is a sequence of tokens. The set of tokens includes six structural characters, strings, numbers, and three literal names. A JSON text is a serialized value. Note that certain previous specifications of JSON constrained a JSON text to be an object or an array."

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant