Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by disabling your ad blocker.

Chaining JavaScript Promises While Sharing Parent Data

Typically when I’m working with RESTful APIs, the routes or endpoints return what I need, plus more, which would be too much data. However, recently I ended up working with an API where the responses were rather trim, resulting in the need to use many HTTP requests to various endpoints, rather than getting everything in a single request. To take it a step further, some of those HTTP requests depended on data from other requests creating a mess of asynchronous operations in JavaScript.

After consulting with my pal, Corbin Crutchley, we came up with a solution to what I needed, without creating chaos in my code. Remember, Corbin is a JavaScript professional, as demonstrated on the podcast we recorded together titled, Asynchronous JavaScript Development.

In this tutorial we’re going to see how to chain JavaScript promises, but also use data from parent links in the promise chain with child links in the same promise chain.

Read More

TPDP Episode #29: Asynchronous JavaScript Development

The latest episode of The Polyglot Developer Podcast has just published, this time focusing on the use of callbacks, promises, and async / await, in JavaScript.

This episode titled, Asynchronous JavaScript Development, is the twenty-ninth episode to appear on the show and it features Corbin Crutchley, an expert JavaScript developer and open source maintainer.

If you’ve ever struggled with wrapping your head around working with remote resources or blocking tasks in JavaScript, this episode should clear things up.

Read More

Image Cropping, Zooming, and Scaling with Angular and JavaScript

When building a web application there is a good chance you’re going to need to work with images eventually, even if it is something as simple as allowing a user to upload a profile image. In theory this is a simple task, but in reality, your website theme is probably anticipating images of a certain resolution or aspect ratio. If the user tries to upload an image that doesn’t meet your requirements, it might break your theme.

We’re going to see how to include image manipulation capabilities in your Angular application using the popular cropperjs JavaScript package.

Read More

Getting Started with Building Chatbots using AWS Lex and Node.js

Amazon and a lot of cloud vendors such as Microsoft and Google have services around machine learning (ML), artificial intelligence (AI), and virtual assistants. A popular one that might come to mind is Amazon Alexa, something I’ve written quite a few tutorials around over the years.

The concept around Alexa is simple. Provide the Alexa service some audio, have that audio converted into text or some other format that can be evaluated, execute some code, and respond with something to be spoken to the user. However, what if you didn’t necessarily want to use a virtual assistant with audio, but integrate as part of a chat application in the form of a chatbot?

In this tutorial we’re going to look at using Amazon Web Services (AWS) Lex, which is a service for adding conversational interfaces to your applications. If you’re coming from an Amazon Alexa background, the concepts will be similar as AWS Lex shares the same deep learning technologies.

Read More

Password Hashing and JWTs for NativeScript Apps with an Express.js Backend

When building an application that allows users to have accounts, you have to ensure that access to these accounts is secure. When building a user account system, an important factor to keep in mind is how passwords are stored. Storing passwords as plain text is a complete rookie move that leaves your users vulnerable to all sorts of data breaches.

The best way to protect passwords is to employ hashing and salting and in this tutorial, we’ll show you exactly how to do this. We’ll also show you how to generate JSON Web Tokens (JWT) on a Node.js server backend that can be used to authenticate and authorize users, as well as how to store those tokens on the client NativeScript application.

Read More

Building a Simple Web Application in Dart

Dart is a programming language developed by Google and made popular by Flutter, their mobile development framework for cross-platform application development.

The Dart language is a general-purpose language, built to be used for far more than just mobile development, and, in this short tutorial, I will show you how to build a basic web application, using Dart.

Read More

Using Socket.io to Create a Multiplayer Game with Angular and Node.js

When it comes to client and server communication, there are quite a few approaches towards solving the problem. You could create a RESTful API or GraphQL API on your server and consume it on-demand with your client, or you can go the socket approach and interact in real-time through events. There isn’t a wrong way to do things, but some ways are better than others given the task at hand.

Let’s take for example gaming and online multiplayer games. While certain aspects of the game would make sense to use REST or GraphQL, not everything would feel responsive enough. Instead it makes sense to use sockets.

In this tutorial we’re going to explore Socket.io for our client and server communication. We’re going to create a Socket.io server with Node.js and that server will communicate with each of our games running as Angular applications.

Read More