Retrieving a certain array out of a promise [duplicate]

  async-await, asynchronous, dom, javascript, json

For example, I have an async function:

“`async function getComments(data = {})` {

videoId = (function()
{

return window.location.search.split(/?|&|=/g)[2];

})();

// Request the current video page again and retrieve required data for loading comments.

var response = await fetch(("https://www.youtube.com/watch?v=" + videoId + "&pbj=1"),
{
method: ‘POST’,
mode: ‘cors’,
cache: ‘no-cache’,
credientials: ‘same-origin’,
headers:
{
‘X-YOUTUBE-CLIENT-NAME’: ‘1’,
‘X-YOUTUBE-CLIENT-VERSION’: ‘1.20200101.01.01’
},
redirect: ‘follow’,
referrerPolicy: ‘strict-origin-when-cross-origin’,
body: JSON.stringify(data)
});

return response.json();
}“`

And the promise returns a result with two arrays. How do I select a specific array? I’m sorry if this is a dumb question with an obvious answer.

enter image description here

Source: Ask Javascript Questions

LEAVE A COMMENT