main.c
main.c

Reputation: 169

Iron Router: No route definitions found

Im developing a basic meteorjs app and using the iron router for client-side-only routing. I set up my routes, publications and schemas but i cant get the iron router to run. It allways shows me "No route definitions found" after i start my app. My router.js is in /lib. Changing its location didnt work at all. I dont have any console logs. Any help is appreciated.

My router.js:

Router.route('/', {
  name: 'main',
  layoutTemplate: 'mainLay',
  waitOn: function() {
    return Meteor.subscribe('posts');
 },
  action: function() {
    this.render('allPosts');
}
 });

 Router.route('/create-post', {
  name: 'createPost',
  layoutTemplate: 'mainLay',
  action: function() {
    if (Meteor.userId()) {
      this.render('createPost');
    }
    else {
    Router.go('/');
   }
  }
 });

Router.route('/post/:postId', {
 name: 'post',
 layoutTemplate: 'mainLay',
 waitOn: function() {
  return [
    Meteor.subscribe('comments', this.params.postId),
    Meteor.subscribe('post', this.params.postId)
  ];
},
action: function() {
  var postId = this.params.postId;
  this.render('postDetail');
}
});

and in my .meteor/packages i have the entry:

iron:router

Upvotes: 0

Views: 2391

Answers (1)

Akarda
Akarda

Reputation: 26

If you not clear about the app structure, that could help: https://guide.meteor.com/structure.html#example-app-structure

That the template can´t be found for the iron-router:

The router.js is not known by the client entrypoint: /client/main.js

client/
  main.js                      # client entry point, imports all client code

in your current case:

inside the main.js check if you add:

import '/lib/router.js';

Upvotes: 1

Related Questions