Dorcas  Ferry

Dorcas Ferry


Tips For Using Async/Await - Write Better JavaScript!

Async/Await is a much cleaner syntax for working with promises than using .then(). Let’s take a look at how to convert an asynchronous function from using .then() to using async/await and learn a few tips along the way.

00:00 - Intro
00:45 - Fetch Example with .then
01:30 - Convert Promises to Async/Await
04:40 - Use Try/Catch for Errors
06:30 - Async Functions Return a Promise
07:40 - Use IIfe for Top-Level Await
09:00 - Promise.all()



What is GEEK

Buddha Community

Tips For Using Async/Await - Write Better JavaScript!
Ray  Patel

Ray Patel


top 30 Python Tips and Tricks for Beginners

Welcome to my Blog , In this article, you are going to learn the top 10 python tips and tricks.

1) swap two numbers.

2) Reversing a string in Python.

3) Create a single string from all the elements in list.

4) Chaining Of Comparison Operators.

5) Print The File Path Of Imported Modules.

6) Return Multiple Values From Functions.

7) Find The Most Frequent Value In A List.

8) Check The Memory Usage Of An Object.

#python #python hacks tricks #python learning tips #python programming tricks #python tips #python tips and tricks #python tips and tricks advanced #python tips and tricks for beginners #python tips tricks and techniques #python tutorial #tips and tricks in python #tips to learn python #top 30 python tips and tricks for beginners

Sadie  Cassin

Sadie Cassin


How To Use Async/Await in JavaScript

How To Use Async/Await in JavaScript



The async and await is keywords to perform the promise-based asynchronous operation. In this article, we are going to learn how to use async/await in JavaScript.

How to use Async?

It is mandatory to define the async keyword before any function that turns your normal function to async function. Let’s start to learn it through a very basic example.

Normal Function Example

function sayHello() {
    return 'Hello World!';

sayHello(); // Hello World!


Async Function Example

async function sayHello() {
    return 'Hello World!';

sayHello(); // [object Promise] { ... }


We could explicitly return a promise with Promise.resolve() like:

async function sayHello() {
    return Promise.resolve('Hello World!');
async function sayHello() {
    return 'Hello World!';

let greeting = sayHello();
greeting.then((value) => console.log(value)); // Hello World!


or you can try this:

async function sayHello() {
    return 'Hello World!';

sayHello().then((value) => console.log(value) ); // Hello World!

#javascript #async #await

Javascript : Async Await in Javascript | Javascript Interview questions.

Explained in detail about

  • Async
  • Await
  • Fetching country data using Async & Await
  • How Async & Await better than promise

Dont miss to watch the video & ask your questions or doubts in comments

#javascript #async #await

Oral  Brekke

Oral Brekke


Using Async/await inside Loops In JavaScript

Iterating through items and dealing with asynchronous logic (i.e. API calls) are probably two of the most common tasks we have to perform as JavaScript devs. In this article, we will discuss the best approaches to combine async/await and iterative logic. There will be a time when you would want to run async operations inside for loops (or any type of other loops). Let’s take a look at how to deal with such situations.

Reading Promises in sequence

Let’s say we have a list of files and we would like to read and log the contents of each file in the sequence. How would we do this? Well, we can use a **for … of the **loop inside an async function. Here’s the code snippet.

async function printFiles () {
  let fileNames = ['picard', 'kirk', 'geordy', 'ryker', 'worf'];
  for (const file of fileNames) {
    const contents = await fs.readFile(file, 'utf8');

💡 Be advised that if you want to read files in sequence you can not use a forEach loop.

#javascript #nodejs #javascript-development #web-development #javascript-tips

Javascript async-await: How to Use ES7 async-await

Javascript async-await feature is used to deal with asynchronous code in javascript. The async-await is a just new technique to write async code in a sync function manner.  You can write it as a simple synchronous function. That makes it very popular and understandable. Node.js is now supporting async-await out of the box.

Async-await is a new way to write asynchronous code. Previous options for asynchronous code are  callbacks and  promises. Async/await built on top of promises. It cannot be used with plain callbacks or node callbacks.


You can read the following tutorials if you do not know anything about Javascript callbacks and promises.

Promises In ES6

Callback in Javascript

#javascript #node.js #async/await