although, in the implementation of addAcronym (and deleteAcronym), I’d rather just return the value of a call to indexView instead of the redirect, so basically return indexView(request).
Awesome tutorials! Advanced course on Vapor would be incredibly beneficial. How to make it secure, advanced interaction with database and etc. Thank you so much!
@goranche Thanks! There is one advantage to using the redirect though (which I should have mentioned in the video)! :]
Imagine you don’t redirect, and return try indexView(request: request) instead. Then when you add an acronym, your browser is displaying the result of the POST to /til, and if you refresh the page, the browser effectively tries to re-post the same acronym (which isn’t desired; really the user probably just wants to refresh the latest list of acronyms). You get a warning like this:
Similarly, in the deleting an acronym case, the browser is displaying the result of a POST to /til/acronymId/delete:
And if you refreshed the browser, it would try and delete that acronym instead.
By redirecting to index, if you refresh the page it doesn’t try to re-add or delete anything. I hope that makes sense, and thanks for pointing this out as I’ll be sure to mention this if I ever cover this again! :]
Hi, did anyone come across this error when playing the video “The media could not be loaded, either because the server or network failed or because the format is not supported.”? I tried both Chrome and Safari.