Stick params middleware not working

19 views
Skip to first unread message

prateek sharma

unread,
May 15, 2013, 12:07:19 AM5/15/13
to rin...@googlegroups.com
Hi all,
I am building a simple web page using ringo. I am trying to use Stick and its params middleware to find my post params.

I have a main.js which configure Stick as below.

var app = exports.app = new Application();

app.configure("gzip", "route", "static", "notfound", "params");

I created a plain simple form which has two entries i.e. 
(1) a text box to enter Host
(2) a text box to enter port

and a submit button.
Clicking submit button will send POST request to server and in main.js i am handling it using 


app.post('/:path', function(request, path) {
          console.dir(request);
}


Now my problem is that when i try to print the request in main.js using console.dir(request) it is not printing postParams in console.

Please let me know where am i going wrong. I am not able to access those two text fields in server side.

Thanks,
Pratz

si...@nekapuzer.at

unread,
May 15, 2013, 5:38:51 AM5/15/13
to rin...@googlegroups.com
hi,
the order of middlewares is important. try this:

app.configure("params", "route", "static", "notfound", "gzip");

simon


prateek sharma

unread,
May 15, 2013, 8:47:57 AM5/15/13
to rin...@googlegroups.com
Gr8, It worked. I am getting postParams in console now but still there is one problem that those two text box values are not coming in postParams.
Is there any other sequence that I need to follow or some other setting that I need to do to access the values?

Thanks,
Pratz

si...@nekapuzer.at

unread,
May 15, 2013, 10:26:23 AM5/15/13
to rin...@googlegroups.com
> Gr8, It worked. I am getting postParams in console now but still there is
> one problem that those two text box values are not coming in postParams.
> Is there any other sequence that I need to follow or some other setting
> that I need to do to access the values?

As a general help, did you see:
http://ringojs.org/tutorial/processingdata.md (has a section "query & post
params")

simon

prateek sharma

unread,
May 15, 2013, 12:22:52 PM5/15/13
to rin...@googlegroups.com

Yes I already looked at this example and I am doing almost the same thing but no luck.

Thanks,
Pratz

--
You received this message because you are subscribed to the Google Groups "RingoJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ringojs+u...@googlegroups.com.
To post to this group, send email to rin...@googlegroups.com.
Visit this group at http://groups.google.com/group/ringojs?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


si...@nekapuzer.at

unread,
May 15, 2013, 12:46:32 PM5/15/13
to rin...@googlegroups.com
> Yes I already looked at this example and I am doing almost the same thing
> but no luck.

okay, mh. I am 99% sure it's a problem with your code (and not a bug in
stick). So you have to either debug harder :) or post all of the source
code somewhere online so we can take a look.

simon

prateek sharma

unread,
May 15, 2013, 1:27:50 PM5/15/13
to rin...@googlegroups.com
Hey Simon,
As the files are very small(one html and one js) so I am attaching them in the mail itself. Please have a look. I am sure I am making something very silly mistake.

Thanks for so fast replies :)

Pratz



 simon

TestStick.zip

prateek sharma

unread,
May 15, 2013, 1:37:48 PM5/15/13
to rin...@googlegroups.com
Forgot to mention that I am using ringojs-0.9 version.

Thanks,
Pratz

si...@nekapuzer.at

unread,
May 15, 2013, 2:10:14 PM5/15/13
to rin...@googlegroups.com
>> Please have a look. I am sure I am making something
>> very
>> silly mistake.

good news: it's not your ringo code. main.js is fine. but your <input>s
don't have a "name" property:

<input type="text" id="host" name="host"/>

it's always something silly like that...

prateek sharma

unread,
May 15, 2013, 8:51:42 PM5/15/13
to rin...@googlegroups.com
Hey Simon,
I don't know from where did you get that but the html file I sent you doesn't contain name property in <input> tag and still it is not working :( 
My html is like this.

<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form action="" method="post">
Host : <input type="text" id="host"/><br>
Port : <input type="text" id="port"/><br>
  <input type="submit" value="Submit"/>
</form>
</body>
</html>


prateek sharma

unread,
May 15, 2013, 8:59:31 PM5/15/13
to rin...@googlegroups.com
Oops.. My mistake. Got it.

Thanks,
Pratz
Reply all
Reply to author
Forward
0 new messages