PUT request in Totaljs

36 views
Skip to first unread message

ar.ba...@gmail.com

unread,
Nov 4, 2014, 1:04:46 PM11/4/14
to tot...@googlegroups.com
I'm new to Totaljs. I wrote a code which try to create user with PUT request with angular factory:

app.factory('User', function($resource) {
return $resource('/register', null, {
register: { method: 'put' }
});
});

In my angular controller, when I click on register button this method run:

$scope.register = function() {
$scope.user = new User({email: $scope.email, password: $scope.password});
$scope.user.$register();
}

It run but in console I got this : Failed to load resource: The network connection was lost.

This is my Totaljs controller:

exports.install = function(framework) {
framework.route('/register', registerPage);
framework.route('/register/', register, ['put']);
};

function registerPage() {
var self = this;
self.view('registerPage')
}

function register() {
var self = this;

// instead add new user I just return an existing user for test
var User = MODEL('user').Schema

User.find(function(err, docs) {
self.json(docs);
});

}

I think this is related to XSS, I am running in debug mode on 127.0.0.1:8000, am I right? What is the solution?
Thanks

Peter Širka

unread,
Nov 4, 2014, 1:08:59 PM11/4/14
to tot...@googlegroups.com, ar.ba...@gmail.com

Hi, this is the solution:

framework.route('/register/', register, ['put', 'xss']);

Thanks and give me a feedback.

Reply all
Reply to author
Forward
0 new messages