How To Handle Promise Inside Promise

In this tutorial, you’ll learn how to handle JavaScript promise inside promise. Sometimes it’s required that the result from a promise is the input to another promise and so on. So, let’s see how a promise inside promise or promise chaining can be implemented. Using Promise Inside Promise Let’s start by creating a project directory called promise_inside. Navigate to the project directory and initialize the project using npm. mkdir promise_insidecd promise_insidenpm initOnce the project has been initialized, install the node module request. [Read More]

Implementing Passport Authentication In Express Node.js

This is the second part of the Building An App Using Express, Sequelize and MySQL tutorial series. In this tutorial, you’ll learn how to go about implementing passport authentication in Express Node.js. You’ll be implementing the passport local strategy in this passport authentication example. Source code from this tutorial is available on GitHub. Getting Started Let’s get started by cloning the source code from the first part of the tutorial series. [Read More]

JavaScript : Find Duplicate Values In An Array

In this quick tutorial, you’ll learn how to find duplicates in an array using JavaScript. For finding duplicate values in JavaScript array, you’ll make use of the traditional for loops and Array reduce method. Using For Loop Let’s see how you can find duplicates in an array using for loop. The logic is you’ll separate the array into two array, duplicate array and unique array. You’ll iterate over the values in the array and push the items into unique list if it already doesn’t exist. [Read More]

Setting Up Sequelize Express MySQL

In this first chapter of the Building an app using Node, MySQL and Express tutorial series, you’ll learn how to go about setting up Sequelize, Node and MySQL. Source code from this tutorial is available on GitHub. Table Of Content Getting Started With Express Adding Sequelize ORM To Express App Creating And Migrating Sequelize Models Fetching Data From MySQL Using Sequelize Getting Started With Express To make things a bit easier I’ll be making use of the express application generator. [Read More]

Choosing the Right Python Framework in 2020: Django vs Flask

Image by Clker-Free-Vector-Images from Pixabay Python is one of the most powerful forms of code in the world right now, and as of 2020, it’s growing rapidly. Utilised by start-up companies and world-class companies like Google, Netflix, and Spotify, there seem to be no limits as to what these coding solutions can provide. However, when implementing Python coding into your own life, one of the biggest decisions you’ll be making is which [Read More]

Conditional Class in Angular

How to set conditional classes in Angular?

You can set the class of an element dynamically using ngClass directive.

[ngClass]="{'red': a < 5 , 'blue' : a > 10}"

From the above code, class red or blue will be set if the conditions are satisfied. If both the conditions are satisfied, then the element is assigned both the classes.

Getting Started With Julia Package Manager

In this tutorial, you’ll learn how to get started with Julia package manager. You’ll be using the package manager to install, update and remove different Julia packages. Using Julia Package Manager Status of Package Installed Add New Packages Update Existing Packages Remove Installed Packages Using Julia Package Manager From your terminal type in julia to move to the Julia prompt. Once you are in the Julia prompt type in the following command to get started with the Julia package manager. [Read More]

How To Access Previous Promise Result In Then Chain

In this tutorial, you’ll learn how to access promise result in .then promise chain. In nested JavaScript Promise, sometimes it’s required to access one promise result in the promise chain. In such cases, you tend to assign promise result to a variable and then access it in promise chain. Let’s have a look at how you can access promise results in the entire chain. function getPromise(i){return new Promise(function(resolve, reject){setTimeout(function(){resolve({"data" : i});}, 2000);})}function queryPromiseChain(){let promiseOneResult;let promiseTwoResult;getPromise(1). [Read More]

How to Make API Calls Inside For-loop In JavaScript/

Making API call inside for loop is a common scenario that we face while creating web applications. In this tutorial, you’ll learn how to make API calls inside for loop in JavaScript. You’ll focus on how to make the API calls asynchronous inside for loop in JavaScript using Promise. Getting Started Let’s assume that you have an array of JSON objects with Ids. [{"Id": 10},{"Id": 20},{"Id": 30},{"Id": 40},{"Id": 50}]You need to iterate through the JSON objects array and for each Id you need to make an API call. [Read More]