If you have any query feel free to chat us!
Happy Coding! Happy Learning!
To add flash messages to more actions, you will need to follow these steps:
connect-flash
package using npm:arduinoCopy code
npm install connect-flash
app.js
file:javascriptCopy code
const flash = require('connect-flash');
javascriptCopy code
app.use(flash());
javascriptCopy code
req.flash('success', 'Post deleted successfully');
javascriptCopy code
const flashMessages = res.locals.messages();
res.render('index', { flashMessages });
ejsCopy code
<% if (flashMessages.success) { %>
<div class="alert alert-success" role="alert">
<%= flashMessages.success %>
</div>
<% } %>
error
message type for displaying error messages:javascriptCopy code
req.flash('error', 'There was an error deleting the post');
And in your view:
ejsCopy code
<% if (flashMessages.error) { %>
<div class="alert alert-danger" role="alert">
<%= flashMessages.error %>
</div>
<% } %>
By adding flash messages to more actions, you can provide better feedback to the user and improve the overall user experience.
Comments: 2
I am not able to access videos from second class and further. I have already completed first class
When will I get my course?
Now, Your query was resolved.