Created
July 13, 2017 03:43
-
-
Save bvenkatr/97ecf602e564efab3e134f0ddf92c03d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
module.exports = function (Todos) { | |
Todos.validatesLengthOf('text', {min: 5, message: {min: 'text is too short'}}); | |
//create a test remote method and do field validations using Validate object | |
Todos.saveTodosData = function (text, done, cb) { | |
Todos.create({text, done}, function (err, data) { | |
cb(err, data); | |
}); | |
}; | |
Todos.remoteMethod("saveTodosData", { | |
accepts: [ | |
{ | |
arg: "text", | |
type: "string", | |
required: true | |
}, { | |
arg: "done", | |
type: "boolean", | |
required: true | |
} | |
], | |
returns: { | |
root: true | |
} | |
}); | |
}; | |
curl -H "Content-Type: application/json" -X POST -d '{"text":"30","done":false}' http://localhost:3001/rzr/api/todos/saveTodosData |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment