Application Android et IOS pour l'amicale des élèves
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

WebData.js 481B

12345678910111213141516171819
  1. // @flow
  2. /**
  3. * Read data from FETCH_URL and return it.
  4. * If no data was found, returns an empty object
  5. *
  6. * @param url The urls to fetch data from
  7. * @return {Promise<Object>}
  8. */
  9. export async function readData(url: string) {
  10. let fetchedData: Object = {};
  11. try {
  12. let response = await fetch(url);
  13. fetchedData = await response.json();
  14. } catch (error) {
  15. throw new Error('Could not read FetchedData from server');
  16. }
  17. return fetchedData;
  18. }