I just started learning meteor and this is my first web app. I’m following a tutorial from YouTube, which was created some years ago. I have completed my application, and everything worked just fine, until I started to make the application more secure by following best practices as advised on the official meteor site and by the video narrator. I’m going to outline the series of events that possibly led to the issue:
First let me explain my folder structure - I have three folders, client, server and lib. In my client folder, there is a main.js and main.html. In my server, there is a main.js, while in the lib folder, there is a collections.js.
The first thing I did was to uninstall the insecure package, and I got a notification that it was successful. Then I started to transfer the insert, remove operations (while including added entry checks) from client/main.js to lib/collections.js which is where I started getting the non-defined error in the console.
I believe it might be from the imports/exports but I have gone through it and can’t seem to know what’s wrong.
In my client/main.js I had these as imports:
import { Template } from 'meteor/templating';
import { Meteor } from 'meteor/meteor';
import { Notes } from '../lib/collections.js';
import { Accounts } from 'meteor/accounts-base';
import './main.html';
In my server/main.js I had these as imports:
import { Meteor } from 'meteor/meteor';
export const Notes = new Mongo.Collection('notes');
In the lib/collections.js I had these as imports:
import { Mongo } from 'meteor/mongo';
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
export const Notes = new Mongo.Collection('notes');
The function definition where the error is coming from is defined in collections.js in lib as:
Meteor.methods({
'notes.insert'(text) {
.
.
.
'notes.remove'(note) {
check(note._id, String);
Notes.remove(note._id);
}
});
The function was invoked like this in the client main.js:
Template.note.events ({
'click .delete-note': function(){
Meteor.call('note.remove', this);
return false;
}
});
The error is that note.remove function is not being called.
Please assist in knowing why note.remove is not being invoked.