Skip to content
This repository was archived by the owner on Sep 1, 2022. It is now read-only.

Commit 18ff985

Browse files
committed
style(methods): move request on top
1 parent e1ca02c commit 18ff985

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

src/lib/sdk.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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',

src/lib/sdk.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)