Posts

Showing posts from 2018

Promise method of Node JS and how it simplifies the callback problem

Hi guys,Today we will see how  we can avoid callback problems by Advanced method of node Provided by Node version 6.5.0 (or further version). Its Promise method.You don't need to include any library for that.Below  is the example. function asyncJobFunction() { var url="mydomain.com"; return new Promise(function(resolve,reject){ //Write here your Async Code call.Get(url,function(err,data) { if(err) { reject(err); ///Reject the Promise by calling the reject method. } else { console.log("Success"); resolve(data); ///Resolve the Promise by calling the resolve method. } }) }) } above we have written one function asyncJobFunction which returns the promise object.so we have to catch the result either resolve or reject. lets see how we can catch that. var promiseData=asyncJobFunction();  promiseData.then(function(result){ console.log("Success"); console.log(result);  /...

Promise method of Node JS and how it simplifies the callback problem

Hi guys,Today we will see how  we can avoid callback problems by Advanced method of node Provided by Node version 6.5.0 (or further version). Its Promise method.You don't need to include any library for that.Below  is the example. function asyncJobFunction() { var url="mydomain.com"; return new Promise(function(resolve,reject){ //Write here your Async Code call.Get(url,function(err,data) { if(err) { reject(err); ///Reject the Promise by calling the reject method. } else { console.log("Success"); resolve(data); ///Resolve the Promise by calling the resolve method. } }) }) } above we have written one function asyncJobFunction which returns the promise object.so we have to catch the result either resolve or reject. lets see how we can catch that. var promiseData=asyncJobFunction();  promiseData.then(function(result){ console.log("Success"); console.log(result);  /...

Introduction to Node JS and How to Overcome Callback Problems in it

Introduction:-  As you all know,Node.js is a server side platform built on Google Chrome's Javascript Engine(V8 Engine).It provides a rich library of various JavaScript modules which simplifies the web development to great extent. Node js runs asynchronously with single thread that's why its faster compare to others. But Sometimes it can make you worry a little because If you have worked on java or other technologies which executes synchoronously,there you dont need to worry about how two functions will execute because those were running synchronously.It can wait one after another. In Node JS,its not the same case.Second function will execute before first function if first function will take time.let me explain you by simple example. var x=0; for (var i=0;i<50;i++) {   x=x+1; } xyz(x); //Calling function xyz console.log("Hello World"); function xyz(x) {    //Time consuming code } In above case,It will first print Hello World before givin...

File Upload and Send it Through AJAX to node.js Server in SAPUI5 Application

Hi team, Today,In this post I will be explaining you how to upload any types of file in SAPui5 application. Actually you will find many techniques over a web for file upload in sapui5.But those techniques will be related to directly passing the media server or gateway server which can store(upload) the file content and also have downlloadable feature. What if you dont have any server and you are also not going to deploy the sapui5 application to fiori sandbox or sap abap sever.In that case you cant buy server just for media upload. So Only way possible is convert the file in base64 format and send it like normal string to server over ajax and store in database or in text file in server and also again use that base64  format to get the actual data back in the actual format. Here i will explain it for sapui5 application and will send to node.js server but it can be used for any Javascript framework just you need to have your uploaded which accepts file from our devices w...