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.

httpUtils.js 778B

12345678910111213141516171819202122232425262728
  1. const logger = require('jitsi-meet-logger').getLogger(__filename);
  2. /**
  3. * Wrapper around fetch GET requests to handle json-ifying the response
  4. * and logging errors.
  5. *
  6. * @param {string} url - The URL to perform a GET against.
  7. * @returns {Promise<Object>} The response body, in JSON format, will be
  8. * through the Promise.
  9. */
  10. export function doGetJSON(url) {
  11. return fetch(url)
  12. .then(response => {
  13. const jsonify = response.json();
  14. if (response.ok) {
  15. return jsonify;
  16. }
  17. return jsonify
  18. .then(result => Promise.reject(result));
  19. })
  20. .catch(error => {
  21. logger.error('Error performing get:', url, error);
  22. return Promise.reject(error);
  23. });
  24. }