Great tutorial, but I think you should provide more tips for beginners. Ok, you want them to learn, but yould show a little more ou maybe something like "Go and try to do that. If you can't, no worries, down below there's a hint for you".
Anyway, for everyone who's having problems with the method store of the EventController, it's because @nilomiranda
tells you to use the following:
constnewEvent=awaitEvent.create({...
But he forgot to mention that you need to import the model to the controller. So, below the 'use strict', just import it like this:
constEvent=use('App/Models/Event')
@arapl3y
said that he was only able to fix the 500 status by changing to:
constnewEvent=awaituser.events().create({...
Yeah, it works, but are at the EventController, so it would be good if the only thing I use is the Event itself to keep things clean. Of course we need to get the authenticated user and pass his id to the creation of the event, but that should be it.
And I strongly recommend you all to use the implementation that @yonglee79
said in his comment. Instead of this:
constuserID=auth.user.id
Do that:
constuser=awaitauth.getUser()
And in the place where you create the event, instad of passing the userID variable, simply do that:
Great tutorial, but I think you should provide more tips for beginners. Ok, you want them to learn, but yould show a little more ou maybe something like "Go and try to do that. If you can't, no worries, down below there's a hint for you".
Anyway, for everyone who's having problems with the method store of the EventController, it's because @nilomiranda tells you to use the following:
But he forgot to mention that you need to import the model to the controller. So, below the
'use strict'
, just import it like this:@arapl3y said that he was only able to fix the 500 status by changing to:
Yeah, it works, but are at the EventController, so it would be good if the only thing I use is the Event itself to keep things clean. Of course we need to get the authenticated user and pass his id to the creation of the event, but that should be it.
And I strongly recommend you all to use the implementation that @yonglee79 said in his comment. Instead of this:
Do that:
And in the place where you create the event, instad of passing the
userID
variable, simply do that:But anyway, great tutorial, @nilomiranda ! And I hope you don''t get angry with my feedback.
Cya!