FxaForm.fetchTokens = function()

in media/js/base/fxa-form.es6.js [117:158]


FxaForm.fetchTokens = function () {
    let destURL = formElem.getAttribute('action') + 'metrics-flow';

    // add required params to the token fetch request
    destURL += '?form_type=email';
    destURL += '&entrypoint=' + entrypointInput.value;
    destURL += '&utm_source=' + utmSource.value;

    if (utmContent) {
        destURL += '&utm_content=' + utmContent.value;
    }

    if (utmCampaign) {
        destURL += '&utm_campaign=' + utmCampaign.value;
    }

    if (utmTerm) {
        destURL += '&utm_term=' + utmTerm.value;
    }

    if (entrypointExp) {
        destURL += '&entrypoint_experiment=' + entrypointExp.value;
    }

    if (entrypointVar) {
        destURL += '&entrypoint_variation=' + entrypointVar.value;
    }

    return fetch(destURL)
        .then((resp) => {
            return resp.json();
        })
        .then((r) => {
            formElem.querySelector('[name="device_id"]').value = r.deviceId;
            formElem.querySelector('[name="flow_id"]').value = r.flowId;
            formElem.querySelector('[name="flow_begin_time"]').value =
                r.flowBeginTime;
        })
        .catch(() => {
            // silently fail, leaving flow_id and flow_begin_time as default empty value
        });
};