SitePoint Sponsor |
|
User Tag List
Results 1 to 14 of 14
-
Nov 14, 2012, 20:15 #1
- Join Date
- Dec 2010
- Posts
- 2
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Chap 1 - Authentication - Submit does nothing?
Thank you for publishing this handy book. I'm completely new to node.js. Not even a programmer. Just trying to employ the latest & greatest tech for an app I've been meaning to build. Therefore, please excuse my idiocy as I ask this ?:
When I click on the submit button for the 'authentication' example, nothing happens. The browser just keeps churning. This happens when I use the github source code as well. Note: I did change the creds for the MongoDB connection. Even tried with my own VPS installation of MongoDB. Same effect. I also created a '/signup' directory in the app.js folder in hopes that would cause the info to post. Anybody else experience this same problem? Please help. Don't want to get discouraged this early in the game. Thanks.
-
Nov 14, 2012, 23:46 #2
- Join Date
- Nov 2012
- Posts
- 48
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Hi timpoppe, sorry to hear you have been having trouble. Quick question did you change all three of the following parameters?
var username = ...
var password = ...
var address = ...
If so, would you be able to post your code I'm sure we can get this quickly resolved
-
Nov 15, 2012, 17:22 #3
- Join Date
- Dec 2010
- Posts
- 2
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Ah Bloody Hell. Me own fault. Wasn't putting in the proper creds. Thanks for responding so soon.
Looking forward to working on the rest of the example tuts.
Great book.
-
Dec 4, 2012, 13:47 #4
I'm having this problem as well but I've entered the user/password/address info. I noticed in the example code there's a space before the address string. I am not able to run node app with this space. I get the same 'browser churning'.
-
Dec 4, 2012, 14:36 #5
after reading another thread, I'm going to try a local install of MongoDB to see if it's a firewall issue.
-
Dec 4, 2012, 19:11 #6
- Join Date
- Sep 2005
- Location
- Sydney, Australia
- Posts
- 776
- Mentioned
- 11 Post(s)
- Tagged
- 0 Thread(s)
var details = {
. . web: "afterlight.com.au",
. . photos: "jvdl.id.au",
. . psa: "usethelatestversion.com"
}
-
Dec 5, 2012, 03:11 #7
- Join Date
- Nov 2012
- Posts
- 48
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
I'm seeing if the white space issue can be fixed up in the repository to avoid any future confusion. Any luck with the local install?
-
Dec 5, 2012, 20:18 #8
It was indeed a firewall issue, I got everything to work! Looking forward to continuing the book now. We are starting to use Node.js for more and more projects at work.
-
Dec 21, 2012, 17:12 #9
- Join Date
- Jun 2010
- Posts
- 4
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi Don, I just went thru chap 1 example. However, could not the the app.post portion to work.
After filling out the form and hit submit, the browser return "Cannot GET /signup?username=john;password=1234".
I did create the app.post section in the app.js just like the book.
What do you think I did wrong?
Thanks
-
Dec 22, 2012, 02:14 #10
- Join Date
- Nov 2012
- Posts
- 48
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
It looks like you don't have a route for /signup. Can you post your code and I will have a look
-
Dec 22, 2012, 10:11 #11
- Join Date
- Jun 2010
- Posts
- 4
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, fs = require('fs')
, User = require('./models/User.js');
var app = module.exports = express.createServer();
// Configuration
app.configure(function(){
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(__dirname + '/public'));
});
app.configure('development', function(){
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
app.configure('production', function(){
app.use(express.errorHandler());
});
// Routes
app.get('/', routes.index);
app.get('/form', function(req, res) {
fs.readFile('./form.html', function(error, content) {
if (error) {
res.writeHead(500);
res.end();
}
else {
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(content, 'utf-8');
}
});
});
// Post
app.post('/signup', function(req, res) {
var username = req.body.username;
var password = req.body.password;
User.addUser(username, password, function(err, user){
if (err) throw err;
res.redirect('/form');
});
});
app.listen(3000);
console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
-
Dec 22, 2012, 22:47 #12
- Join Date
- Nov 2012
- Posts
- 48
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
One other thing the following error message
Cannot GET
Looks a bit strange. In your form.html do you have method="POST" ?
-
Dec 23, 2012, 02:09 #13
- Join Date
- Jun 2010
- Posts
- 4
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Here is my form.html:
<form action="/signup" methond="post">
<div>
<label>Username/label>
<input type="text" name="username"/><br />
</div>
<div>
<label>Password/label>
<input type="password" name="password" />
</div>
<div><input type="submit" value="Sign UP"/></div>
</form>
-
Dec 23, 2012, 02:12 #14
- Join Date
- Jun 2010
- Posts
- 4
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Don, never mind.
I just realized that I misspell "method".
It's always the most obvious.
Bookmarks