kaazing / http2-cache.js

2 stars 11 forks source link

Update FormDate to be used under Node only for non proxy request #31

Closed hthetiot closed 7 years ago

tejaede commented 7 years ago

@dpwspoon Tested and verified.

dpwspoon commented 7 years ago

LGTM, thanks @hthetiot

tejaede commented 7 years ago

@hthetiot Snippet of a representative request sent from Contour that requires FormData.

var data = {"product_id": 173130, "app_id":"18","comment_text":"","create_Date":"2017-07-27T19:54:34.632Z","geo_locations":"","title":"TJ Test Product","timeline_date":"1501185262685","update_Date":"2017-07-27T19:54:34.632Z","data":"Test","is_hidden":"N","file_name":"","file_upload":"","product_type":"TEXT_PRODUCT","security_flag":"A"},
    formData = new FormData(),
    key;

for (key in data) {
    formData.append(key, data[key]);
}
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
    if (xhr.readyState === 4) {
        console.log("EditProductResponseText", xhr.responseText);
    }
};
xhr.withCredentials = true;
xhr.open('POST', "https://testemops.pdc.org/hp_srv/services/products/2/json/edit_product", true);
xhr.send(formData);