ES6 promise chaining example — July 15, 2018

ES6 promise chaining example

var asyncAdd = (a, b) => {
    return new Promise((resolve, reject) => {
       setTimeout(()=>{
	   if( typeof a === 'number' && typeof b === 'number' ) {
		resolve(a+b);
           } else {
		reject('Arguments must be numbers only');
	   }
       },1500);
    });
};


var result = asyncAdd(5,7);

result.then((result)=>{
	console.log(`Success:-${result}`);
        //this is how we can chain promise. return a new promise again in result.
	return asyncAdd(result, 33);
}).then((result)=>{
	console.log(`Success Chained:-${result}`);
}).catch((errorMessage)=>{
    console.log(`Error :-${errorMessage}`);
});
Advertisements
CSS indent text — July 13, 2018
Ubuntu Nginx enable ssl — June 12, 2018

Ubuntu Nginx enable ssl

There are so many blogs and videos about this topic but this video worked for me. It has all the information about ssl from start. So the steps in installing ssl involve

1.Create a Certificate Signing Request( CSR )
2.Submit the CSR to your service provider
3.Retrieve your new cert
4.Upload your new cert and private key to your server
5.Configure Nginx
chrome redirecting localhost Or vhost domains to https — June 1, 2018
Javascript createElement and add new attribute to it — May 31, 2018
Laravel 5.6 assign value to variable in blade template — May 21, 2018
bootstrap-select library not working with bootstrap 4 — May 20, 2018

bootstrap-select library not working with bootstrap 4

We need to use the latest css and js files for bootstrap-select. So use version 1.13.0

The old versions of bootstrap-select does not work with bootstrap 4. also do these steps

1. add class="selectpicker" and data-live-search="true"to your select
2. add data-tokens to your options. The live search will look into these data-token element when performing the search.

For more details check this answer on stackoverflow.