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 505B

123456789101112131415161718192021
  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. return new Promise((resolve, reject) => {
  11. fetch(url)
  12. .then(async (response) => response.json())
  13. .then((data) => {
  14. resolve(data);
  15. })
  16. .catch(() => {
  17. reject();
  18. });
  19. });
  20. }