title: How to return result from api call (with promise-based Axios library) to calling scope?
body: <p>I know this topic is covered in many questions. I have read many of them but couldn't translate the information to my situation as there are many frameworks for both Promises and making asynchronous HTTP requests. The more I read, the more confused I get. So I kindly ask for your help on this 
  task. I will try to keep it as specific as possible.</p>
  
  <p><strong>This is what I want to do:</strong></p>
  
  <p>A user enters a search term and by submitting an api call is made to the Wikimedia API, requesting Wikipedia pages for that search term. This results in a list of pages, which can be normal pages or meta pages. I want to filter out the meta pages.</p>
  
  <pre><code>// the first call to the API, requesting the sources(pages)
  axios.get(url, {params})
    .then(function (res) {
      const html = res.data[1].map((source) =&gt; {
        // here I want to filter meta pages 
        if (isNotMetaPage(source)) {
          return `
            &lt;div class='sources_list_entry'&gt;
              &lt;p&gt; ${source} &lt;/p&gt;
            &lt;/div&gt;
          `
        }
      }).join('')
  </code></pre>
  
  <p>In the function <code>isNotMetaPage()</code> I need to make another API call to Wikipedia, to get the page type (it is not included in the first request) and return <code>true</code> for a normal page and <code>false</code> for meta pages. </p>
  
  <pre><code>function isNotMetaPage (title) {
  
    const encodedTitle = encodeURI(title)
    const query = `?action=query&amp;titles=${encodedTitle}&amp;prop=revisions&amp;rvprop=content&amp;format=json&amp;origin=*`
    let result
  
    axios.get(url.concat(query))
      .then(function (response) {
        const wikiPage = parseWikiMarkup(response)
        result = (wikiPage.type === 'page')
    })
  
    return result
  }
  </code></pre>
  
  <p>Obviously, this function returns <code>undefined</code>, as the request is asynchronous and and result is returned before the API replies. When logging the result to the console inside the <code>then</code>-block it has the right value. </p>
  
  <p>But how can I pause the execution until I have the result back? I read a lot that I should not make synchronous calls, but how can I avoid it here?</p>
  
  <p>Appreciate your help!</p>