Ignore:
Timestamp:
01/21/25 03:08:24 (3 days ago)
Author:
stefan toskovski <stefantoska84@…>
Branches:
main
Parents:
0c6b92a
Message:

F4 Finalna Verzija

File:
1 edited

Legend:

Unmodified
Added
Removed
  • imaps-frontend/src/scripts/net/HttpService.js

    r0c6b92a r79a0317  
    55    constructor(auth = false) {
    66      this.auth = auth;
     7      this.responseType = 'json';
    78    }
    89
     
    1011        this.auth = true;
    1112    }
     13    setResponseType(type){
     14        if(type === 'text'){
     15            this.responseType = 'text';
     16        } else if (type === 'json'){
     17            this.responseType = 'json'
     18        } else {
     19            console.error('unsupported response type in http service')
     20        }
     21    }
     22
    1223
    1324    async request(method, endpoint, data = null) {
     
    5364
    5465      console.log("HTTPSERVICE: RESPONSE:",response);
    55  
    56       return response.json();
     66
     67      if(this.responseType === 'json'){
     68          return response.json();
     69      } else if (this.responseType === 'text'){
     70          return response.text()
     71      } else{
     72          console.error('bad resp type')
     73      }
    5774    }
    5875 
Note: See TracChangeset for help on using the changeset viewer.