New to coding and using meteor. Deployment issue - meteor

I have created a very simple app to start out my learning process. I used the meteor deployment steps and I receive this error on the page.
Router.route('/', function () {
this.render('Home', {
data: function () { return Items.findOne({_id: this.params._id}); }
});
});
I have searched online about it and unfortunately I do not have the router knowledge to understand many of the answers. I will put my routing code here:
Router.configure({
layoutTemplate:'layout'
});
Router.route('/', function () {
this.render('home');
});
Router.route('/red', function () {
this.render('red');
});
Router.route('/yellow', function () {
this.render('yellow');
});
Router.route('/green', function () {
this.render('green');
});
Router.route('/home', function () {
this.render('home');
});
It routes fine in the localhost. If anyone could help me or poit me in the correct direction that would really help. I am extremely new to this (started last week) so please understand that. Thank you.

The issue was actually from the demo js that existed in the meteor template. Once I deleted the code from that js it works great!

Related

Deploying a meteor app from Meteor Galaxy Error: iron:router No route definitions found

I have deployed my meteor app from Meteor Galaxy. This works fine, but when I enter the address http://perfilesgs.meteorapp.com/, this shows me an error that the route has not been found.
If you need more information that I can give you to solve this problem tell me. I will be careful.
Thanks.
lib/router.js
var request = require('request');
var cheerio = require('cheerio');
var json2csv = require('json2csv');
Router.configure({
layoutTemplate: 'layout',
loadingTemplate: 'loading',
notFoundTemplate: 'notFound'
});
Router.route('/', {
name: 'home'
});
Router.route('/inicio', {
name: 'buscador'
});
Router.route('/results/', function () {
this.redirect('/inicio');
});
var requireLogin = function() {
if (! Meteor.user()) {
if (Meteor.loggingIn()) {
this.render(this.loadingTemplate);
} else {
this.render('accessDenied');
}
} else {
this.next();
}
}
Tested independently, the code you provided seems to work properly. I think that other errors in your code are preventing the client-side iron-router code from executing. I see two errors on the browser console:
Fix these (both seem trivial), and I imagine iron-router should work as expected. Update the question if this is not the case.

Client shows all collections as empty

I am having trouble getting the client to find entries in a collection in a Meteor application.
This seems to be a common question and I have tried all the suggestions I have come across. For now, autopublish is included, so as far as I can tell the problem shouldn't be with publishing/subscribing.
I even went back and went through the simple-todo tutorial on meteor.com and meticulously checked each step. As soon as I replace my array with a collection, the collection comes up empty.
All I can think to do is wipe out my meteor install and reinstall, but I would really like to know what is causing this.
printTypes = new Mongo.Collection("printTypes");
if (Meteor.isClient) {
Meteor.subscribe("printTypes");
Router.configure({
loadingTemplate: 'homePage'
});
Router.map( function () {
this.route('itemPage', {
path: '/item',
waitOn: function() {
return Meteor.subscribe('printTypes');
},
data: function () {
templateData = { printTypes: printTypes.find({}) };
return templateData;
}
});
});
}
if (Meteor.isServer) {
Meteor.startup(function () {
Meteor.publish("printTypes", function () {
return printTypes.find();
});
});
}
Any ideas? Thanks!

Meteor Update to 1.0.4.2 App Broken, Iron Router not working

I just updated to 1.0.4.2 now my routes are not being run. Loading my app gives me an Iron Router splash page that says this
Router.route('/', function () {
this.render('Home', {
data: function () { return Items.findOne({_id: this.params._id}); }
});
});
UPDATE: It wasn't Meteor, it was this package https://github.com/grigio/meteor-babel. They removed the .jsx extension.

"Object is not a function" in a Meteor route

I just created two routes that work just fine, but I'm getting an odd error in the console that I would like to fix.
Exception in callback of async function: TypeError: object is not a function
at OnBeforeActions.loginRequired (http://localhost:3000/client/router/config.js?8cea1a53d7ab131377c2c4f91d534123cba79b70:12:20)
This error shows up every time I visit the same page.
This is my config.js file:
Router.configure({
layoutTemplate: "uMain"
});
var OnBeforeActions = {
loginRequired: function (pause) {
"use strict";
if (!Meteor.userId()) {
this.render("uLogin");
return pause();
} else {
this.next();
}
}
};
Router.onBeforeAction(OnBeforeActions.loginRequired, {
except: ["uLogin"]
});
The idea is to redirected all user who are not logged in to "uLogin".
It works (or I haven't found any bugs so far).
What am I doing wrong?
You can see the line where you have the error in developers console when you click on link http://localhost:3000/client/router/config.js?8cea1a53d7ab131377c2c4f91d534123cba79b70:12:20 in your console.
Your problem is that new Iron Router does not use pause() anymore. Remove pause from your onBeforeAction.
Developers console is your good friend. Learn how to use it.

Meteor Iron Router Run function when collection changes

Im new to Meteor and Im trying to figure out how to run a function after a collection change.
I have a route(iron router) that subscribes to a collection with waitOn. Which just waits for the subscrition to be ready before rendering which is what I want.
waitOn: function () {
return Meteor.subscribe('collection', this.params._id);
},
Any changes to the collection will be updated on all the clients and rendered automatically.
How would I run a function once the collection has changed?
You can use the onData hook, provided that you're returning that data using the data helper. E.g this is what a route may look like
this.route('routename',
path : '/abc',
waitOn: function () {
return Meteor.subscribe('collection', this.params._id);
},
data: function() {
return Collection.findOne({_id: this.params.id});
}
onData: function() {
//Do something when the data found by the above changes
}
});

Resources