I can not find my problem. Does anyone see what I'm doing wrong? This project has been completed using Meteor and React.
My import file:
import _ from 'lodash';
import { lorem, faker } from 'faker';
import { Comments } from '../../api/comments/comments';
import { insertComment } from '../../api/comments/methods.js';
import { Bert } from 'meteor/themeteorchef:bert';
Meteor.startup(() => {
// Great place to generate some data
// Check to see if data excists in the collection
// See if the collection has any records
const numberRecords = Comments.find({}).count();
if (!numberRecords) {
// Generate some data...
_.times(100, () => {
const title = faker.lorem.title();
const content = faker.lorem.title();
insertComment.call({
title, content,
}, (error) => {
if (error) {
Bert.alert(error.reason, 'danger');
} else {
target.value = '';
Bert.alert('Comment added!', 'success');
}
});
});
}
});
Run codeAnd this is the method file that I use to write a comment:
import { Comments } from './comments';
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
import { ValidatedMethod } from 'meteor/mdg:validated-method';
import { rateLimit } from '../../modules/rate-limit.js';
export const insertComment = new ValidatedMethod({
name: 'comments.insert',
validate: new SimpleSchema({
title: { type: String },
content: { type: String },
}).validator(),
run(comment) {
Comments.insert(comment);
},
});
rateLimit({
methods: [
insertComment,
],
limit: 5,
timeRange: 1000,
});
Run codeThis is the error code I get in my terminal: TypeError: it is not possible to read the lorem property from undefined.
Any help is greatly appreciated.
EDIT:
As suggested, I made changes to the import from "import {lorem, faker] from" faker ";" import faker from "faker"; "
I also changed this to "faker.lorem.title ();" on "faker.hacker.noun ();"
Thank Guig