2 Ways to Cancel a Request in Axios

September 21, 2022 Snowball

This concise and straight-to-the-point article shows you 2 distinct ways to cancel a recently sent request in Axios. Without any further ado, let’s get started. Using AbortController If you’re developing a project with a new version…

Axios: How to Set Timeouts for Requests

September 21, 2022 Snowball

In Axios, the default timeout is 0. This quick and straightforward article shows you a few ways to set custom timeouts when making HTTP requests with Axios. Set Timeout for a single Request You can set…

Axios: Set Headers in GET/POST Requests

September 18, 2022 Snowball

This quick and straight-to-the-point article shows you how to set headers when sending GET and POST requests with Axios. Without any further ado (like talking about what Axios is or rambling about its history), let’s get…

Axios: Passing Query Parameters in GET/POST Requests

September 15, 2022 Snowball

This quick and at-a-glance article shows you how to pass query parameters in a GET or POST request when using Axios, a very popular Javascript HTTP library. Passing Query Params in a GET Request Axios syntax…

Moment.js: Subtract 2 Dates and Format the Result

September 15, 2022 Snowball

In order to subtract 2 dates with Moment.js, you can follow the steps below: 1. Construct moment date objects from your date strings: 3. Let’s say dateTwo is the minuend and dateOne is the subtrahend. We’ll…

Moment.js: Subtracting Time from a Date

September 15, 2022 Snowball

To subtract time from a given date with moment.js, just follow the steps below: 1. Create a moment object with your date: 2. Construct a duration object from your time string with the moment.duration() method: 3….

Javascript: Subtracting Days/Hours/Minutes from a Date

September 7, 2022 Snowball

There will be many cases where you need to subtract a number of days/hours/minutes/seconds from a given date object. The following examples will demonstrate how to do that in Javascript. In the first example, we’re just…

2 Ways to Format Currency in Javascript

September 7, 2022 Snowball

In Javascript, you can format currency strings in 2 different ways: Intl.NumberFormat() Number.toLocaleString() Both of these approaches work on all modern web browsers and Node.js No third-party libraries are required. Example of using Intl.NumberFormat: Output: Example…

Javascript: Convert Relative URLs to Absolute URLs

September 1, 2022 Pennywise

In Javascript, you can easily convert a relative URL to an absolute URL like so: This works well regardless your relative URL starts with a slash (“/”) or not. Below is a concrete example: Output: Alternative…

Javascript: Using Async/Await with Loops

August 18, 2022 Snowball

The demo program below shows you how to use the async/await syntax with a for loop in modern Javascript: When running this program, you will see the tasks are executed sequentially one after another, and the…

VS Code: Set Preferred Quote Type for Quick Fixes

July 27, 2022 A Goodman

When working with Javascript and TypeScript, arbitrary use of single quotes and double quotes may not cause errors but will result in a lack of consistency and readability. Therefore, choosing and going with a certain quote…

CSS & Javascript: Change Background Color on Scroll

September 1, 2022 Pennywise

The example below shows you how to dynamically change the background color of a webpage when the user scrolls down. We only use CSS and vanilla Javascript to make this. Example Preview The full code Explanation…

1 2 3