MCPcopy
hub / github.com/ampproject/amphtml / invoke

Function invoke

src/impression.js:219–234  ·  view source on GitHub ↗

* Send the url to ad server and wait for its response * @param {!Window} win * @param {string} clickUrl * @return {!Promise<?JsonObject>}

(win, clickUrl)

Source from the content-addressed store, hash-verified

217 * @return {!Promise<?JsonObject>}
218 */
219function invoke(win, clickUrl) {
220 if (getMode().localDev && !getMode().test) {
221 clickUrl = 'http://localhost:8000/impression-proxy?url=' + clickUrl;
222 }
223 return Services.xhrFor(win)
224 .fetchJson(clickUrl, {
225 credentials: 'include',
226 })
227 .then((res) => {
228 // Treat 204 no content response specially
229 if (res.status == 204) {
230 return null;
231 }
232 return res.json();
233 });
234}
235
236/**
237 * parse the response back from ad server

Callers 1

handleClickUrlFunction · 0.85

Calls 4

getModeFunction · 0.90
fetchJsonMethod · 0.80
thenMethod · 0.45
jsonMethod · 0.45

Tested by

no test coverage detected