Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 142239

Returning the result from nestled .then to another function

$
0
0

I can't work out or understand how to return the nestled .then methods resolved value to the function that called it.

How can I return the value from the resolved promise that is nestled to the and then console.log() in that function that calls it.

  connectedCallback () {
    this.input.addEventListener('input', event => {
      this.search(this.input.value)
    })
  }

  search (str) {
    let searchResult = window.fetch(`http://localhost:3000/api/?q=${str}`)
      .then(result => {
        return result.json()
          .then(result => {
            return result
          })
      })
  }
}

Viewing all articles
Browse latest Browse all 142239

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>