Я пытаюсь выяснить, как вызвать функцию toastr из конечной точки nodejs
toastr
Вот пример html рабочего примера отображения сообщения toastr при нажатии кнопки.
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/1.3.1/js/toastr.js"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/1.3.1/css/toastr.css"> <script> $(function () { $('#success').click(function () { toastr.success("Added successfully!"); }); }); </script> </head> <body> <div class="container"> <h2>Toaster</h2> <form> <input type="button" value="Success" id="success" class="btn btn-success" /> </form> </div> </body> </html>
Вот мой NodeJS код: Как бы я назвал toastr здесь?
app.get('/', (req, res) => { //res.send('awesome'); //this does not work.... req.toastr.success('Successfully logged in.', "You're in!"); });