* Send the url to ad server and wait for its response * @param {!Window} win * @param {string} clickUrl * @return {!Promise<?JsonObject>}
(win, clickUrl)
| 217 | * @return {!Promise<?JsonObject>} |
| 218 | */ |
| 219 | function 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 |
no test coverage detected