Closed jobe451 closed 11 years ago
For now I fixed my problem by replacing line 193 of connect-rest.js with:
if(!req.query && req._parsedUrl.query !== undefined) req.query = req._parsedUrl.query;
else if(!req.query ) req.query = {};
Let me check this query and get back to you very soon ...
rest.get( '/data/items', function( request, content, callback ){ console.log( 'Received:' + JSON.stringify( request ) ); return callback(null, 'ok'); }); Received:{"headers":{"accept-version":"2.2.0","host":"localhost:8080","connection":"keep-alive","clientAddress":"127.0.0.1"},"parameters":{"ids":["8","9"]}}
so you can have your parameters in the rest function by calling: request.parameters.ids
Let me know if you deal with any other issue...
Thanks for this very quick response and your help. Unfortunately, I still have the same problem..
I do this get-request: http://localhost:8080/data/assets?ids%5B%5D=7&ids%5B%5D=8
The rest-function looks like this: rest.get('/data/items', function (request, content, callback) { logger.debug(request); logger.debug(request.parameters); logger.debug(request.parameters.ids); }
I get in logs: [2013-04-26 00:44:14.559] [DEBUG] Webserver - { headers: { host: 'localhost:8080', connection: 'keep-alive', accept: 'application/json, text/javascript, /; q=0.01', 'x-requested-with': 'XMLHttpRequest', 'user-agent': 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safar i/537.31', 'content-type': 'application/json; charset=utf-8', referer: 'http://localhost:8080/', 'accept-encoding': 'gzip, deflate', 'accept-language': 'de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4', 'accept-charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3', clientAddress: '127.0.0.1' }, parameters: {} } [2013-04-26 00:44:14.560] [DEBUG] Webserver - {} [2013-04-26 00:44:14.560] [DEBUG] Webserver - undefined
request.paramters is always an empty object.
I tried this on node version 0.8.20 and version 0.10.5. I call from chrome 26.
2013/4/26 Imre Fazekas notifications@github.com
rest.get( '/data/items', function( request, content, callback ){ console.log( 'Received:' + JSON.stringify( request ) ); return callback(null, 'ok'); });
Received:{"headers":{"accept-version":"2.2.0","host":"localhost:8080","connection":"keep-alive","clientAddress":"127.0.0.1"},"parameters":{"ids":["8","9"]}}
so you can have your parameters in the rest function by calling: request.parameters.ids
— Reply to this email directly or view it on GitHubhttps://github.com/imrefazekas/connect-rest/issues/2#issuecomment-17044513 .
Strange.
I put your code into my test. rest.get('/data/items', function (request, content, callback) { console.log( '>>>>' + request.parameters.ids ); return callback(null, 'ok'); } );
and by opening a page in safari using this url: http://localhost:8080/data/items?ids%5B%5D=7&ids%5B%5D=8
output is: >>>>7,8
are you sure you are adding connectApp.use( connect.query() ); before using my rest middleware?
I found the problem. In order to have the query values available, it needs to have this 'middleware' in the chain first: server.use(connect.query());
If this is in place, it works as you described. Thanks for your help!
Hi
Thanks first of all for this awsome library.
I try to use it as backend for an emberjs project. Some emberjs rest calls come with additional GET-parameters like this: http://localhost:8080/data/items?ids%5B%5D=8&ids%5B%5D=9
I can get connect-rest to receive / handle this request. However, I don't have the GET-query (ids%5B%5D=8&ids%5B%5D=9) available in the request nor content parameters. How should I deal with this kind of calls?