mardi 30 décembre 2014

Sending data 5 items throw a loop and receiving 7?


Vote count:

0





var ordered = {
actions: [
'index', // GET /
'new', // GET /new
'create', // POST /
'show', // GET /:id
'edit', // GET /edit/:id
'update', // PUT /:id
'patch', // PATCH /:id
'destroy', // DEL /:id
],
methods: [
'get',
'post',
'put',
'patch',
'delete'
]
};


I'm making a loop in the ordered.methods and passing to a prototype, but i'm receiving wrong in the prototype.



ordered.methods.forEach(function(method){
Resource.prototype[method] = function(path, fn) {
if ('function' == typeof path || 'object' == typeof path) {
fn = path, path = '';
}
this.map(method, path, fn);
return this;
}
});


When i do a console.log in the method in the looping, the data is right, just the get, post, put, patch and delete is showing, but when i try to do a console.log in the Resource.prototype.map, this is showing in my console:



get
get
post
get
get
put
delete


How can i fix that?



asked 18 secs ago







Sending data 5 items throw a loop and receiving 7?

Aucun commentaire:

Enregistrer un commentaire