Changeset 79a0317 for imaps-frontend/src/scripts/net/HttpService.js
- Timestamp:
- 01/21/25 03:08:24 (3 days ago)
- Branches:
- main
- Parents:
- 0c6b92a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/src/scripts/net/HttpService.js
r0c6b92a r79a0317 5 5 constructor(auth = false) { 6 6 this.auth = auth; 7 this.responseType = 'json'; 7 8 } 8 9 … … 10 11 this.auth = true; 11 12 } 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 12 23 13 24 async request(method, endpoint, data = null) { … … 53 64 54 65 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 } 57 74 } 58 75
Note:
See TracChangeset
for help on using the changeset viewer.