[Vuejs]-Problems sorting consumed API data

1👍

Based on your comments it seems to me you should be doing it like this:

mounted () {
    axios
      .post('https://api.regobs.no/v4/Search', {'NumberOfRecords': '10', 'SelectedGeoHazards': '[70]', 'Extent': { 'TopLeft': { 'Latitude': '60.14', 'Longitude': '10.21' }, 'BottomRight': { 'Latitude': '60.04', 'Longitude': '10.35' }}},  { headers: {'Content-Type': 'text/json'}})
      .then(response => {
           this.info = response.data;
           this.sortering();
      } );
  }

You want to wait for the response to arrive, set this.info and then call the function.

EDIT

So, I managed to get it to work. You have two culprits:

  1. {{ forfattere(authors) }} – Refactor this, it’s causing infinite loops

  2. This line of code:

<span :class="[ tykkelsen ? 'green' : 'red']">{{ sjekkTykkelsen(item[2].IceThicknessSum) }} cm</span>

This is also causing the infinite loop.

Here is a working sandox: https://codesandbox.io/s/funny-lumiere-v00c2

Leave a comment