How to Query a JSON Column in PostgreSQL

As a software engineer, it is common to store structured data in a relational database such as PostgreSQL, or unstructured data in a non-relational database such as Mongo DB. Luckily, PostgreSQL allows defining column types as json and jsonb, which are two JSON (JavaScript Object Notation) data types that allow storing unstructured data in a … Read more

(Solved) Argument of type ‘() => Promise’ is not assignable to parameter of type ‘EffectCallback’

I’ve been using useEffect hooks heavily since React introduced them in version 16.8. A way to think of Effect hooks is like React lifecycle method (componentDidMount, componentDidUpdate, componentDWillUnmount) bundled into one function, or hook as React defines it to perform side effects in function components. Recently I came across the error Argument of type ‘() … Read more

(Solved) Property ‘allSettled’ does not exist on type ‘PromiseConstructor’

Recently I learned about the Promise.allSettled() method which generates a single promise from an array of promises similar to the Promise.all() method, with the main difference that Promise.allSettled() runs all the promises passed regardless if a promise is rejected. I initially was using Promise.all() for logic in a NodeJs Express application using TypeScript. However, after … Read more

How to make redirects from the server side using NextJS?

Whether you recently changed the path of your articles from /blog/[article-slug] to articles/[article-slug], or you need to redirect a user to the login screen to authenticate prior to granting access to a page, learning how to do redirects on the server side is an effective way to avoid React doing unnecessary rendering on the client … Read more

How to Use Enums in JavaScript? Defining a Custom Object

If you come from a Typescript background or any other languages like C++, Python, etc., you must have come across Enums. Although “enum” is a reserved keyword in Javascript, Enums don’t really exist in Javascript, but you can “kind of” create them yourself, as you will learn in this post. An enum is a short … Read more

(Solved) Cannot Convert Undefined or Null to Object in JS

The error “TypeError: Cannot convert undefined or null to object” happens when JavaScript attempts to convert null and undefined to an object. Below you can see examples of when this error occurs. In the previous example, notice how the Object.assign() , Object.keys() , and Object.values() methods expect a parameter o equivalent to any JavaScript object … Read more

(Solved) TypeScript Array.find() possibly ‘undefined’

Errors like “TS2532: Object is possible ‘undefined’” can happen after defining the value of a variable by using the array.find() method. Here are the possible reasons why thearray.find() method returns undefined: The predicate parameter or callback function passed to the array.find() doesn’t explicitly use the return keyword to return a truthy value. The predicate parameter … Read more

TypeScript | A Practical Guide to Use Extends in TypeScript

With the introduction of ECMAScript 2015, commonly known as ES6, you can implement object-oriented programming as a class-based approach in JavaScript/TypeScript. Before that, JavaScript developers would use the prototype-based approach to implement the object-oriented pattern in their code. Similar to object-oriented languages like Java and C#, now TypeScript developers can use various object-oriented features like interfaces, inheritance, … Read more

How to Print a Raw Pointer in Rust?

The other day I wrote an article about the dereference unary operator (*) and I needed a way to explain the unary operator by first explaining about pointers in Rust, which are the memory address location of, for example, a variable. However, I didn’t know how to print the pointer of a variable, without displaying … Read more