MCPcopy Index your code
hub / github.com/apache/pouchdb / fetchJSON

Function fetchJSON

lib/index-browser.js:6872–6909  ·  view source on GitHub ↗
(url, options)

Source from the content-addressed store, hash-verified

6870 }
6871
6872 async function fetchJSON(url, options) {
6873
6874 const result = {};
6875
6876 options = options || {};
6877 options.headers = options.headers || new h();
6878
6879 if (!options.headers.get('Content-Type')) {
6880 options.headers.set('Content-Type', 'application/json');
6881 }
6882 if (!options.headers.get('Accept')) {
6883 options.headers.set('Accept', 'application/json');
6884 }
6885
6886 const response = await ourFetch(url, options);
6887 result.ok = response.ok;
6888 result.status = response.status;
6889 const json = await response.json();
6890
6891 result.data = json;
6892 if (!result.ok) {
6893 result.data.status = result.status;
6894 const err = generateErrorFromResponse(result.data);
6895 throw err;
6896 }
6897
6898 if (Array.isArray(result.data)) {
6899 result.data = result.data.map(function (v) {
6900 if (v.error || v.missing) {
6901 return generateErrorFromResponse(v);
6902 } else {
6903 return v;
6904 }
6905 });
6906 }
6907
6908 return result;
6909 }
6910
6911 let setupPromise;
6912

Callers 4

setupFunction · 0.70
HttpPouchFunction · 0.70
doBulkGetFunction · 0.70
fetchDataFunction · 0.70

Calls 3

ourFetchFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…