I want to asynchronously replace a part of the string
var str = "abc"
var str2 = str.replace(/a/g,m=>{
new Promise(r=>r("x"),j=>j("rejected"))
.then(result=>result)
})
console.log(str2)
I tried using async/await:
var str = "abc"
var str2 = str.replace(/a/g, async(m)=>{
return await new Promise(r=>r("x"),j=>j("rejected"))
.then(result=>result)
})
console.log(str2) //[object Promise]bc