fix
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||||
|
import { Observable } from 'rxjs/Rx';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@@ -9,12 +10,12 @@ export class UserService {
|
|||||||
//constructor() { }
|
//constructor() { }
|
||||||
apiKey = '99dfe35fcb7de1ee';
|
apiKey = '99dfe35fcb7de1ee';
|
||||||
url;
|
url;
|
||||||
oauth_url: string = "https://savvyoauth2.sworks.chiefsoft.net/api/v1";
|
|
||||||
|
|
||||||
constructor(private http: HttpClient) {
|
constructor(private http: HttpClient) {
|
||||||
console.log('Hello UserService Provider');
|
console.log('Hello UserService Provider');
|
||||||
this.url = 'https://www.chiefsoft.net/SAVVY/user';
|
this.url = 'https://oameye.svrjuba.works.jubabox.com/JUBA/user/';
|
||||||
this.url = 'https://adminsavvy.sworks.float.sg/SAVVY/user';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -23,4 +24,76 @@ export class UserService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sendGetRequest(grp: string, endPoint: string, sendData: any) {
|
||||||
|
// grp - will be used to change URL
|
||||||
|
var endpoint_string ="";
|
||||||
|
console.log("GRP->"+grp);
|
||||||
|
switch(grp){
|
||||||
|
case '1':
|
||||||
|
endpoint_string =this.url;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '2':
|
||||||
|
endpoint_string=this.url;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
let httpParams = new HttpParams();
|
||||||
|
if (sendData) {
|
||||||
|
for(let k in sendData) {
|
||||||
|
httpParams.set(k, sendData[k]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Observable.fromPromise(new Promise(resolve => {
|
||||||
|
this.http.get(endpoint_string + endPoint, { params: httpParams }).subscribe(data => {
|
||||||
|
// console.log(data);
|
||||||
|
// console.log("*************************************************");
|
||||||
|
/* var payload = this.decrypt(
|
||||||
|
this.encryptionIV,
|
||||||
|
data["payload"],
|
||||||
|
this.encryptionKey);*/
|
||||||
|
console.log(payload);
|
||||||
|
var payload = data['payload'];
|
||||||
|
resolve(JSON.parse(payload));
|
||||||
|
}, error => {
|
||||||
|
console.log("Error");
|
||||||
|
}, () => {
|
||||||
|
console.log("OK!");
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
sendPostRequest(grp: string, endPoint: string, sendData: any) {
|
||||||
|
// grp - will be used to change URL
|
||||||
|
var endpoint_string ="";
|
||||||
|
console.log("GRP->"+grp);
|
||||||
|
switch(grp){
|
||||||
|
case '1':
|
||||||
|
endpoint_string =this.url;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '2':
|
||||||
|
endpoint_string=this.url;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//return this.http.post(this.url + endPoint, sendData);
|
||||||
|
return Observable.fromPromise(new Promise(resolve => {
|
||||||
|
this.http.post(endpoint_string + endPoint, sendData).subscribe(data => {
|
||||||
|
console.log(data);
|
||||||
|
console.log("*************************************************");
|
||||||
|
/* var payload = this.decrypt(
|
||||||
|
this.encryptionIV,
|
||||||
|
data["payload"],
|
||||||
|
this.encryptionKey);
|
||||||
|
*/
|
||||||
|
var payload = data['payload'];
|
||||||
|
console.log(payload);
|
||||||
|
resolve(JSON.parse(payload));
|
||||||
|
}, error => {
|
||||||
|
console.log("Error");
|
||||||
|
}, () => {
|
||||||
|
console.log("OK!");
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user