Posts

Showing posts from April, 2020

Creating Login and Registration Application Using NodeJS and MySQL!

Image
Creating Login and Registration Application Using NodeJS and MySQL Creating Login and Registration Application Using NodeJS and MySQL rather than using any Programming Languages to interact with back-end databases, we are going to use ExpressJS which gives us very good flexibility over Node.js.  To start with this application required following 1. NodeJS 2. ExpressJS 3. MySQL Install NodeJS $  npm install node Install ExpressJS $ npm install express --save Install MySQL $ npm install mysql--save Create a database by simply typing a command mysql> create database test; Check your database exist in your databases list simply type a command mysql> show databases;  Choose the database to work around with select database by typing command mysql> use test; Create a users table in that database. To create a users table type command CREATE TABLE `users`(`id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(255) NOT NULL, `password` ...

How to generate PDF of a website page with Node.js

Image
In this article, we will see how easy it is to generate PDF of any webpage using Nodejs and send the generated pdf back to the client side application Step 1 $ npm install -g html-pdf Nodejs Code example for Creating PDF of web Page var fs = require('fs'); var pdf = require('html-pdf'); var html = fs.readFileSync('./mybus.html', 'utf8'); var options = { format: 'Letter' }; pdf.create(html, options).toFile('./mybus.pdf', function(err, res) { if (err) return console.log(err); console.log(res); // { filename: '/app/mybus.pdf' } }); //mybus.html can replace with any html file. according to your application.

How to Add Timer in Node js Code?

Image
Adding timer In Node Js Example Code var array = ['some', 'array', 'containing', 'words']; var interval = 1000; // how much time should the delay between two iterations be (in milliseconds)? var promise = Promise.resolve(); array.forEach(function (el) {   promise = promise.then(function () {     console.log(el);     return new Promise(function (resolve) {       setTimeout(resolve, interval);     });   }); }); promise.then(function () {   console.log('Loop finished.'); });