Commit 3d943e1 1 parent a1a61c7 commit 3d943e1 Copy full SHA for 3d943e1
File tree 1 file changed +29
-0
lines changed
1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ const axios = require ( 'axios' ) ;
2
+ const CfxEndpoints = require ( '../enum/Endpoints' ) ;
3
+ const AxiosConfig = require ( '../constant/AxiosConfig' ) ;
4
+ const CitizenServer = require ( '../model/CitizenServer' ) ;
5
+
6
+ class CitizenServerModule {
7
+ static self = null ;
8
+
9
+ static get ( ) {
10
+ if ( this . self === null ) {
11
+ this . self = new CitizenServerModule ( ) ;
12
+ }
13
+ return this . self ;
14
+ }
15
+
16
+ async retrieve ( id ) {
17
+ try {
18
+ const response = await axios . get ( CfxEndpoints . CFX_MASTERLIST + id , AxiosConfig ) ;
19
+ if ( response . status !== 200 ) {
20
+ new Error ( 'Server not found or internal error occurred' ) ;
21
+ }
22
+ return new CitizenServer ( response . data ) ;
23
+ } catch ( error ) {
24
+ console . log ( 'Error: ' + error ) ;
25
+ }
26
+ }
27
+ }
28
+
29
+ module . exports = CitizenServerModule ;
You can’t perform that action at this time.
0 commit comments