MCPcopy Create free account
hub / github.com/decaporg/decap-cms / fetchJson

Function fetchJson

scripts/publish-packages.mjs:117–138  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

115}
116
117async function fetchJson(url) {
118 for (let attempt = 1; attempt <= FETCH_ATTEMPTS; attempt += 1) {
119 try {
120 const response = await fetch(url, { headers: { accept: 'application/json' } });
121 if (response.status === 404) {
122 return null;
123 }
124 if (response.ok) {
125 return response.json();
126 }
127 if (attempt === FETCH_ATTEMPTS) {
128 throw new Error(`registry responded ${response.status}`);
129 }
130 } catch (e) {
131 if (attempt === FETCH_ATTEMPTS) {
132 throw e;
133 }
134 }
135 await delay(FETCH_RETRY_DELAY_MS);
136 }
137 throw new Error('exhausted registry retries');
138}
139
140// Scoped names must have their separator encoded to address a single version.
141function encodeName(name) {

Callers 3

isVersionPublishedFunction · 0.70
packageExistsFunction · 0.70

Calls 1

delayFunction · 0.70

Tested by

no test coverage detected