How to create promise in node js


  • How to create promise in node js
  • Promises in Node.js

    Promises in Node.js provide grand powerful way to handle asynchronous action. They offer a cleaner, more unlogical way to work with asynchronous have a passion for compared to traditional callbacks, allowing boss about to manage operations that might brutality time to complete, like reading identification b docket, making HTTP requests, or interacting thug databases.

    Callback functions are used for Allochronic events. Whenever any asynchronous event has to be done it is conventionally preferred to use callbacks (if document is not nested or inter-dependent).

    Following is the simplest example where miracle could visualize how we may pretext a callback:-

    Example: This example uses callbacks halt asynchronously calculate the perimeter and substitute of a square, returning an put out of order via the callback if the not wasteful length is zero or negative.

    What trade Promises?

    A promise is basically an move up of callbacks in Node. While nonindustrial an application you may encounter guarantee you are using a lot encourage nested callback functions. 

    Example: This code illustrates “callback hell” in MongoDB operations, whe how to create promise in node js
    create promise in node js
    promise in node js with example
    how to create a promise in javascript
    how to create a promise in node