I have a promise object returned by an asynchronous function as it is shown bellow
function funcOne(data){
let myArray = []
fetch("/upload", {
"method":"POST",
"headers":{
"Content-Type":"application/json; charset=utf-8"
},
"body":JSON.stringify(data)
}).then(function(response){
return response.text();
}).then(function(data){
myArray["error"] = data;
});
return myArray;
}
I want to obtain the stored value in myArray
inside funcTwo
function funcTwo(data){
let value = funcOne(data);
console.log(value);
}
This is the output: