I am trying to add a REST API to my Meteor application using Restivus
I putted the following code in server folder of my Meteor application. Currently, I am trying to get the URL parameters.
var Api = new Restivus({
useDefaultAuth: true,
prettyJson: true
});
Api.addRoute('login/:id/:password', {authRequired: true}, {
get:{
action: function(){
var id = this.queryParams.id;
var password = this.queryParams.password;
return {
id: id,
password: password
}
}
}
});
I got this response
{
"status": "error"
"message": "API endpoint does not exist"
}
to my request:
http://localhost:3000/api/login?id=BGrZbGtKZZQYr9jDR&password=myPassword
the way you wrote the url
login/:id/:passwordmeans it is expecting the url to behttp://localhost:3000/api/login/BGrZbGtKZZQYr9jDR/myPasswordHowever in your code, you are looking at the
queryParamsnoturlParams:You should choose one or the other:
use the code:
with the
/login/:id/:passwordURL,or use the route with just
/loginand pass the params as query params to use as you described:http://localhost:3000/api/login?id=BGrZbGtKZZQYr9jDR&password=myPassword