Articles

How to Use Callback in Node.js

by Sachin Joshi SEO/ SMO Consult

node.js-logo.png


A callback is a function which is highly used in node js. When we want to run any task after the success or completion of a given task then we will use a callback. We will write maximum API in such a way that they will support callback.


when we write localhost:3000/sum/23 on the browser then first it will call to the app.get('/sum/:num', sumCallback); routes. Then it will go to the sum function there we pass callback then we check number exists or not  if the number exists then on the success of the function we will move further else we will display error.


In else case we will call one more function sum there we also write one more callback. If sum function will return any result then inside sum callback will occur and display the result.

We will use most to the function using a callback in node.js.


Read more about How to Use Callback in Node.js visit Findnerd.


Sponsor Ads


About Sachin Joshi Innovator   SEO/ SMO Consult

37 connections, 0 recommendations, 89 honor points.
Joined APSense since, May 14th, 2015, From Dehradun, India.

Created on Dec 31st 1969 18:00. Viewed 0 times.

Comments

No comment, be the first to comment.
Please sign in before you comment.