Не в состоянии контролировать выполнение кода Извлечь - PullRequest
0 голосов
/ 15 апреля 2019

Я вызываю fetch внутри функции, но операторы выполняются не так, как я хочу.

getHubspotData('https://api.hubapi.com/deals/v1/deal/paged?hapikey=demo&properties=dealname&properties=dealstage&properties=closedate&properties=dealtype&properties=type&properties=hubspot_owner_id&properties=amount&properties=notes_last_updated&includeAssociations=true');

function getHubspotData(url){
    console.log("URL: "+url);
        fetch(url)
    .then((resp) => resp.json()) // Transform the data into json
    .then(function(data) {
console.log("Inside Fetch");
    })
    console.log("Outside Fetch");
}

Сначала выполняется оператор Outset Fetch, а затем Inside Fetch.

Как сделать так, чтобы код внутри Fetch выполнялся первым, чтобы вывод был

Inside Fetch
Outside Fetch
...