This repository was archived by the owner on Sep 1, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +24
-24
lines changed
Expand file tree Collapse file tree 2 files changed +24
-24
lines changed Original file line number Diff line number Diff line change @@ -22,11 +22,11 @@ test('Create an instance', t => {
2222 Object . getOwnPropertyNames ( Object . getPrototypeOf ( t . context . strapi ) ) ,
2323 [
2424 'constructor' ,
25+ 'request' ,
2526 'register' ,
2627 'login' ,
2728 'forgotPassword' ,
2829 'resetPassword' ,
29- 'request' ,
3030 'getEntries' ,
3131 'getEntry' ,
3232 'createEntry' ,
Original file line number Diff line number Diff line change @@ -22,6 +22,29 @@ export default class Strapi {
2222 } ) ;
2323 }
2424
25+ /**
26+ * Axios request
27+ * @param method Request method
28+ * @param url Server URL
29+ * @param requestConfig Custom Axios config
30+ */
31+ public async request (
32+ method : string ,
33+ url : string ,
34+ requestConfig ?: AxiosRequestConfig
35+ ) : Promise < any > {
36+ try {
37+ const response : AxiosResponse = await this . axios . request ( {
38+ method,
39+ url,
40+ ...requestConfig
41+ } ) ;
42+ return response . data ;
43+ } catch ( error ) {
44+ throw new Error ( error . response . data . message ) ;
45+ }
46+ }
47+
2548 /**
2649 * Register a new user.
2750 * @param username
@@ -113,29 +136,6 @@ export default class Strapi {
113136 } ) ;
114137 }
115138
116- /**
117- * Axios request
118- * @param method Request method
119- * @param url Server URL
120- * @param requestConfig Custom Axios config
121- */
122- public async request (
123- method : string ,
124- url : string ,
125- requestConfig ?: AxiosRequestConfig
126- ) : Promise < any > {
127- try {
128- const response : AxiosResponse = await this . axios . request ( {
129- method,
130- url,
131- ...requestConfig
132- } ) ;
133- return response . data ;
134- } catch ( error ) {
135- throw new Error ( error . response . data . message ) ;
136- }
137- }
138-
139139 /**
140140 * List entries
141141 * @param contentType
You can’t perform that action at this time.
0 commit comments