Skip to main content

Posts

Showing posts with the label node js features and angularjs

Node.js Error First Callback - Error Handling

First I would like to share about “ What is callback? ” and after share about “ Error first callback ” in Node.js. A callback is an asynchronous function which is being called when an Ajax request/call is completed. The Node.js is using much more callback because the entire node APIs use it. What is “Error First Callback” in Node.js? The “ Error first callback ” is used to pass an error and data. The first argument to these functions is an error object and the second argument represents to the success data. So, you can check the first argument as an error object and the second argument as data. If nothing wrong happen in your app use data. Example, var successCallback = function (callback) { this._get( function (error, data) { if (error) { console .log (error); return ; } else { callback( null , data); } }); }; The error first callback pattern just requires that your function accepted two parameters and the first...

Node.js and NPM Examples

The Test examples, //Test NodeJs example var http = require( 'http' ); http.createServer( function (req, res) { res.writeHead( 200 , { 'Content-Type' : 'text/plain' }); res.end( 'Hello NodeJs, I am Anil \n ' ); }).listen( 1337 , "127.0.0.1" ); References,                     i.             https://egghead.io/lessons/node-js-installing-node-js-and-npm-on-windows                   ii.             https://blog.risingstack.com/node-js-windows-10-tutorial/                 iii.             https://howtonode.org/how-to-install-nodejs    ...

How to update Node.js and NPM?

It is very simple to update Node.js and NPM same as like your other software. Update to Node.js, simply go to Node.js official site and download Windows , Mac and Linux installer, and then execute the installer. Now your latest version of Node.js is updated on your machine. References, https://egghead.io/lessons/node-js-installing-node-js-and-npm-on-windows https://blog.risingstack.com/node-js-windows-10-tutorial/ https://howtonode.org/how-to-install-nodejs https://docs.npmjs.com/getting-started/installing-node https://www.npmjs.com/package/node-windows

Where not to use Node.js?

The below are some listed points over where we are not using Node.js? a)       Nested callback hell. b)      In Node.js , any CPU intensive computation will block the responsiveness. c)       Dealing with files can be a bit of a pain. d)      In Node.js, the relational database is a bit of a pain. e)       It's asynchronous programming model not for synchronous model.

Where to use Node.js?

The ability to handle the thousands of concurrent connections with single process and minimum overhead using the JavaScript developed the server applications and networking applications. Some highlighted Node.js points are, a)       Single Page Applications b)      Streaming Data c)       A Real-time Applications like online games, collaboration tools and chat rooms etc. d)      I/O bound Applications e)       APIs based Applications f)        JSON based Applications g)       PROXY Applications

Features of Node.js

a)        It is an asynchronous and event-driven system. b)        Single-threaded event-driven system c)        It is very   lightweight and fast. d)        Tolling e)        Easy to configure f)         Node never buffering g)        It is highly scalable but single threaded. h)        Safe and secure.