0

I am using the following code and my aim is to get the data from the data section of the PromiseResult object of the returned Promise. I am using the following code:

const promiseComment = axios.post(`${BASE_URL}/api/addComment/`, data, getDefaultHeaders());

let allPromises = []

allPromises.push(promiseComment)

Promise.all([allPromises])
    .then(function (values) {
        console.log(values[0][0]);
    });

When I console the values, I get the following response, what I need is the data section from the response which I marked in the following image.

enter image description here

Thanks in advance

Web World
  • 21
  • 4

1 Answers1

1

you need to resolve the promise inside

const promiseComment = axios.post(`${BASE_URL}/api/addComment/`, data, getDefaultHeaders());

let allPromises = []

allPromises.push(promiseComment)

Promise.all([allPromises])
    .then(values=>values).then(obj=>console.log(object.data));