'how to replace part of a string in javascript and wait for the task to finish before continuing with rest of code
let searchKeyword = 'hi'
Array[lastIndex]= await Array[lastIndex].replace(searchKeyword,'user_id:12345,"email":mail') /*wait for this line of code to finish executing, before continuing on with rest of code */
logger.info('hi')
do i have to use promises, I tried using await but it says await has no affect on this type of expression. i have more code but this is just the basic idea I am trying to accomplish, I am still new with asynchronous programming and learn about await and promises
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
