Tags: letters javascript async promises
Dear Vishi, dear logs for today.
In JavaScript, asynchronous operations often return a Promise. A Promise represents a value that may be available now, later, or never if an error occurs.
Let's look at a method that makes a GET request. The function is asynchronous and returns a Promise, which is either resolved with the server response or rejected if an error occurs.
const data = await fetchData(
url,
params,
options
).catch(() => {
showError('Request failed')
})
The await keyword pauses the execution of the current async function until the Promise returned by fetchData is settled. This allows the code to wait for the result before continuing, making asynchronous code easier to read compared to traditional Promise chaining.
The older you get, the more you relaize that luck is nothing but more exposure.
If you just sit in the same chair, same routine, talking to same people…nothing new happens.
You have to touch the world to win: