[Vuejs]-Accessing the JSON fulfillmentValue value

0👍

The Amazon API function getKeywordStats is returning a Promise – it’s an asynchronous operation. This means the function doesn’t return the result like a normal synchronous function, instead it returns a Promise object which you can then register a callback function (via then) to be called once the data is retrieved. Be sure to read up on how promises work; I won’t go into detail here since there’s lots of information about them already.

Move the API call into your component created hook:

export default {
  data() {
    return {
      terms: null
    }
  },

  created() {
    amazon.getKeywordStats('trump aftershock', 0, null, 'de').then(terms => {
      this.terms = terms
    })
  }
}

Leave a comment