AnsweredAssumed Answered

prevent making thousands of calls to the API from web page? Is there a better way?

Question asked by Jewell Simon on Sep 10, 2019
Latest reply on Sep 13, 2019 by Jewell Simon

I want to display the analytics for observees to the observers. On the observers page >

```

/profile/observees/

 ```  in order to do so the api calls that I would need to call are:

```

//api/v1/users/self/ --to get the user id
/api/v1/users/:user_id/observees/ - -using the initial api call to substitute for user id to get an array of the ids
//api/v1/users/:user_id/page_views -- pass in each id history to display to parents (repeat api call for each student)

```

I am using the fetch api to get the information:

```

const apiTest = () => {
  const url1 = "/api/v1/";
  const options = {
    'credentials''same-origin',
    'headers': {
      'accept''application/json'
    },
    'timeout'5000
  };
  fetch("/api/v1/users/self/"options)
  beep boop
        })
        ).then(res => {
          blah blah

        }).etcetera);
}
apiTest();

```

and then innerHTML to display information fetched.

Is there a better approach to this?

I feel like I am going to breeze through our API cap or something.

Outcomes