i am new to meteor, as i followed your document but i am on the collection page its not working as per the suggested steps in the guide. I am using the new version 1.3 and its frustrating if the guide steps not working so where should i look up for how to work with meteor. The data is not fetching from the database shows nothing it gets inserted but not pulling back as per the steps.
Dropdown you code pls
Inside client folder-
main.html**
//head>
title>simple
head>
I have removed starting bracket as its rendering html
Inside client folder-
main.js**
import ‘…/imports/ui/body.js’;
import ‘…/imports/api/tasks.js’;
Inside imports folder there are two folders ui and api
tasks.js inside api folder
import { Mongo } from ‘meteor/mongo’;
export const Tasks = new Mongo.Collection(‘tasks’);
body.html inside ui folder
body>
div class=“container”>
header>
h1>Todo List
/header>
ul>
{{#each tasks}}
{{> task}}
{{/each}}
/ul>
/div>
/body>
body.js inside ui folder
import { Template } from ‘meteor/templating’;
import { Tasks } from ‘…/api/tasks.js’;
import ‘./body.html’;
Template.body.helpers({
tasks() {
return Tasks.find({});
},
});
then i entered the data from cmd by doing meteor mongo and then
db.tasks.insert({ text: “Hello world!”, createdAt: new Date() });
Data shows in mongo shef when i connect it but i am not able to fetch this data…
Did you remove autopublish package ?
no i have not removed this packaage
I have the same issue. My data was successfully inserted, but it is not fetching from the database. I’ve also followed the steps in getting started guide for simple-todos app.
is your sever file being imported correctly? thats the problem most of the time i see these issues
Try to insert this line in server/main.js
import {Tasks} from '../imports/api/tasks.js'
nothing changed its same…
how can i check , whether my server file is being imported or not?
easiest way is to use a console.log statement in your server file and see if it gets executed in your cmd
looks like in the tutorial the server file is outside of the imports folder so it should be imported automatically
import { Meteor } from ‘meteor/meteor’;
console.log(‘hi’);
Meteor.startup(() => {
// code to run on server at startup
});
i did this but console is blank i am very new to meteor so do not have much idea…
are you on this step?
https://www.meteor.com/tutorials/blaze/collections
can you post your file structure
yes i am following same tutorial…
.meteor
client>main.css>main.html>main.js
imports
api>tasks.js
ui>body.js>body.html
node_modules
server
.gitignore
package.json
so you are saying the data is in the mongo…can you check if it is on the client.
Type Task.find().fetch() in your chrome console or w/e browser u are using
i am using google chrome
Task is not defined
this is the error what i am receiving on writing this
Task.find().fetch()
sorry, Tasks not Task…its the name of your collection which u defined
export const Tasks = new Mongo.Collection(‘tasks’);
this is what i have written in tasks.js with this ling when i type on console Tasks.find().fetch()
this error comes VM1596:1 Uncaught ReferenceError: Tasks is not defined(…)
but when i write only Tasks = new Mongo.Collection(‘tasks’); this is tasks.js then in the console it is showing object and data inside that but not in the browser
can you remove this import link form client/main.js
import '../imports/api/tasks.js';