Not sure what the error means: iron router's error: requires url

47 views Asked by At

I applied iron router to my metoer project. The error shows, enter image description here

the iron router code is listed as such

//show nothing when iron router cannot find the path
Router.configure({
    notFoundTemplate: "notFound"
});

Router.route('/',function(){
    this.route('home',{path:'/'});
});

Router.route('/alive', {
    where: 'server'
}).get(function () {
    //write headers
    writeHeaders(this);
    //send our response...
    this.response.end(' ');
})

function writeHeaders(self) {
    self.response.statusCode = 200;
    self.response.setHeader('Content-type','application/json');
    self.response.setHeader('Access-Control-Allow-Origin','*');
    self.response.setHeader('Access-Control-Allow-Headers','Origin, X-Requested-With, Content-Type,  Accept');
}

I am not sure how to reoslve this issue because I don't know what url is required. Any ideas are appreciated.

2

There are 2 answers

0
Touchstone On BEST ANSWER

This is the meteor router that affects only the back-end. https://forums.meteor.com/t/how-to-make-restful-api-using-meteorjs/44008/3

0
Touchstone On

After referring to https://github.com/iron-meteor/iron-router/blob/devel/Guide.md#named-routes, I followed the guide and changed my code.

Router.route('/', function () {
  this.render('Home');
}); 

The exception is then resolved.