DEV Community

Prathamesh More
Prathamesh More

Posted on

Answer: How to use sweetalert in nodejs?

Here you can do using EJS

var express = require('express');
var router = express.Router();
router.post('/add', function(req, res, next) {
   res.status(201).render('new', { isAdded : true } );
});

In HTML side

<% if (isAdded) { %>
 <script>
  Swal.fire(
     'Good job!',
     'Data saved',
     'success'
 )
</script>
<% } %>

Top comments (0)