Reputation: 115
I have changed both files as far as commas and semicolons, both of which have been driving eslint crazy. Nothing seems to appease it within factory.js especially, but the odd error messages that I am getting below make me think this may be something else. Anyone have any experience with this?
UserSeeder.js
const Factory = use('Factory');
const Database = use('Database');
class UserSeeder {
async run () {
const user = await Factory
.model('App/Models/User')
.create()
const users = await Database.table('users');
console.log(users);
}
}
module.exports = UserSeeder;
factory.js
const Factory = use('Factory');
const Hash = use('Hash');
Factory.blueprint('App/Models/User', () => {
return {
username: 'test',
email: '[email protected]',
password: await Hash.make('test'),
}
});
And the lovely and informative error message:
SyntaxError: Unexpected identifier
1 _preLoadFiles.forEach
D:\Source\VuePractice\intro-to-vuetify-with-
adonis\server\node_modules\@adonisjs\ignitor\src\Ignitor\index.js:375
2 Ignitor._loadPreLoadFiles
D:\Source\VuePractice\intro-to-vuetify-with-
adonis\server\node_modules\@adonisjs\ignitor\src\Ignitor\index.js:367
3 Ignitor.fire
D:\Source\VuePractice\intro-to-vuetify-with-
adonis\server\node_modules\@adonisjs\ignitor\src\Ignitor\index.js:760
Upvotes: 2
Views: 1305
Reputation: 775
In my case it was just a typo that I had in my start/routes.js file.
It gave me the next error.
And i solved it removing the extra character. I hope it helps anyone with the same error.
Upvotes: 0
Reputation: 885
The issue you have in your code is that you are using the keyword await
in your Factory for App/Models/User
and the callback isn't async
.
It needs to be:
const Hash = use('Hash')
const Factory = use('Factory')
Factory.blueprint('App/Models/User', async () => {
return {
username: 'test',
email: '[email protected]',
password: await Hash.make('test'),
}
})
Upvotes: 3