-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.txt
113 lines (91 loc) · 3.12 KB
/
api.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
For maintaining
add one folder config in asset
after that create file
environment.json:
{
"apiURL": "http://rfcampaigndev.ril.com/", this is for domain
"login2fUrl": "http://commonutilsdev.ril.com/loginSrv/login2fa",
"validateotp": "http://commonutilsdev.ril.com/loginSrv/validateOTP",
"apiurls": {
"save_image": "ewastetran/saveImageToNAS",
"getTypesOfItems":"ewastetran/getItemMaster",
"getimage": "ewastetran/getAttachment",
"save_pledge":"ewastetran/savePledge"
}
}
and also add this endpoint in enviorment/environment.ts
Then create app-init service file to load all endpoint before application load
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { environment } from '../../../environments/environment';
@Injectable()
export class AppInitService {
constructor(private httpClient: HttpClient) {
}
init(): Promise<any> {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(null);
}, 500);
});
}
loadUrls(): Promise<any> {
const promise = this.httpClient.get('./assets/config/environment.json')
.toPromise()
.then((env: any) => {
environment.apiURL = env.apiURL
environment.validateotp = env.validateotp
environment.login2fUrl = env.login2fUrl
environment.apiurls = env.apiurls
return env;
});
return promise;
}
}
in loadUrls have to maintain all key which is maintained in config to load all endpoint
After that have to call that service app module to use that service:
For sevice we import service in providers
then add that in
providers:[
AppInitService,
{ provide: APP_INITIALIZER, useFactory: init, deps: [AppInitService], multi: true },
{ provide: APP_INITIALIZER, useFactory: loadUrls, deps: [AppInitService], multi: true },
]
export class AppModule { }
export function init(appInitService: AppInitService) {
return () => appInitService.init();
}
export function loadUrls(appInitService: AppInitService) {
return () => appInitService.loadUrls();
}
after all this add servie in app module or in project to use api call
example:
create one service file names as dataservie.service.ts
in that
create function
commonGet(url){
return this.http.get(url);
}
and use this function in component where have to call that api
example
callAPI(){
this.dataService
.commonGet(
environment['apiURL'] + environment['apiurls']['getTypesOfItems']
)
.subscribe((res: any) => {
console.log('================', res);
})
}
and call this function in ngOnint to load that function in page load only
{
'imageID': file data,
'campaignID':1, // hardcode
'imageName': file_name,
'imageURL': file_name,
'NoOfItem':1,
'ItemName':selected item value
}
@jds:registry=http://10.26.61.34:8081/repository/npm-group/
//10.26.61.34:8081/repository/npm-group/:_authToken=NpmToken.27493d2d-feac-38ac-ad54-a107f5b818e0
registry=https://registry.npmjs.org/