svghmi/widget_jsontable.ysl2
branchsvghmi
changeset 3195 cdd2a032b424
parent 3189 0733114a2090
child 3232 7bdb766c2a4d
equal deleted inserted replaced
3191:26b7c4aa7b38 3195:cdd2a032b424
    23             console.log("HTTP fetch error, message = " + e.message + "Widget:" + this.element_id);
    23             console.log("HTTP fetch error, message = " + e.message + "Widget:" + this.element_id);
    24         }
    24         }
    25 
    25 
    26         do_http_request(...opt) {
    26         do_http_request(...opt) {
    27             this.abort_controller = new AbortController();
    27             this.abort_controller = new AbortController();
    28             const query = {
    28             return Promise.resolve().then(() => {
    29                 args: this.args,
    29 
    30                 range: this.cache[1],
    30                 const query = {
    31                 position: this.cache[2],
    31                     args: this.args,
    32                 visible: this.visible,
    32                     range: this.cache[1],
    33                 extra: this.cache.slice(4),
    33                     position: this.cache[2],
    34                 options: opt
    34                     visible: this.visible,
    35             };
    35                     extra: this.cache.slice(4),
    36 
    36                     options: opt
    37             const options = {
    37                 };
    38                  method: 'POST',
    38 
    39                  body: JSON.stringify(query),
    39                 const options = {
    40                  headers: {'Content-Type': 'application/json'},
    40                      method: 'POST',
    41                  signal: this.abort_controller.signal
    41                      body: JSON.stringify(query),
    42             };
    42                      headers: {'Content-Type': 'application/json'},
    43 
    43                      signal: this.abort_controller.signal
    44             return fetch(this.args[0], options)
    44                 };
    45                     .then(this.handle_http_response_bound)
    45 
    46                     .then(this.spread_json_data_bound)
    46                 return fetch(this.args[0], options)
    47                     .catch(this.fetch_error_bound);
    47                         .then(this.handle_http_response_bound)
    48 
    48                         .then(this.spread_json_data_bound)
    49         }
    49                         .catch(this.fetch_error_bound);
       
    50             });
       
    51         }
       
    52 
    50         unsub(){
    53         unsub(){
    51             this.abort_controller.abort();
    54             this.abort_controller.abort();
    52             super.unsub();
    55             super.unsub();
    53         }
    56         }
    54 
    57