MCPcopy Index your code
hub / github.com/ampproject/amphtml / fetch

Method fetch

third_party/subscriptions-project/swg.js:13435–13452  ·  view source on GitHub ↗

* @param {string} input URL * @param {?FetchInitDef} init Fetch options object. * @return {!Promise<!FetchResponse>}

(input, init)

Source from the content-addressed store, hash-verified

13433 * @return {!Promise<!FetchResponse>}
13434 */
13435 fetch(input, init) {
13436 init = setupInit(init);
13437 return this.fetch_(input, init)
13438 .catch((reason) => {
13439 /*
13440 * If the domain is not valid for SwG we return 404 without
13441 * CORS headers and the browser throws a CORS error.
13442 * We include some helpful text in the message to point the
13443 * publisher towards the real problem.
13444 */
13445 const targetOrigin = parseUrl(input).origin;
13446 throw new Error(
13447 `XHR Failed fetching (${targetOrigin}/...): (Note: a CORS error above may indicate that this publisher or domain is not configured in Publisher Center. The CORS error happens becasue 4xx responses do not set CORS headers.)`,
13448 reason && reason.message
13449 );
13450 })
13451 .then((response) => assertSuccess(response));
13452 }
13453}
13454
13455/**

Callers 7

runTestsFunction · 0.45
test-xhr.jsFile · 0.45
fetchMethod · 0.45
sendSubscriptionStateMethod · 0.45
sendEvent_Method · 0.45
getPropensityMethod · 0.45

Calls 6

fetch_Method · 0.95
catchMethod · 0.80
setupInitFunction · 0.70
parseUrlFunction · 0.70
assertSuccessFunction · 0.70
thenMethod · 0.45

Tested by

no test coverage detected