feima-shortcuts 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/generateApi/index.js +3 -8
package/package.json
CHANGED
package/src/generateApi/index.js
CHANGED
|
@@ -142,22 +142,17 @@ export const request = <T>(
|
|
|
142
142
|
options: ApiRequestOptions
|
|
143
143
|
): CancelablePromise<T> => {
|
|
144
144
|
return new CancelablePromise((resolve, reject, onCancel) => {
|
|
145
|
-
// Get the request URL. Depending on your needs, this might need additional processing,
|
|
146
|
-
// @see ./src/templates/core/functions/getUrl.hbs
|
|
147
145
|
const url = \`\${config.BASE}\${options.path}\`;
|
|
148
|
-
|
|
149
|
-
// Optional: Get and link the cancelation token, so the request can be aborted.
|
|
146
|
+
|
|
150
147
|
const source = service.CancelToken.source();
|
|
148
|
+
|
|
151
149
|
onCancel(() => source.cancel("The user aborted a request."));
|
|
152
150
|
|
|
153
|
-
// Execute the request. This is a minimal example, in real world scenarios
|
|
154
|
-
// you will need to add headers, process form data, etc.
|
|
155
|
-
// @see ./src/templates/core/axios/request.hbs
|
|
156
151
|
service
|
|
157
152
|
.request({
|
|
158
153
|
url,
|
|
159
154
|
data: options.body,
|
|
160
|
-
|
|
155
|
+
...options,
|
|
161
156
|
cancelToken: source.token,
|
|
162
157
|
})
|
|
163
158
|
.then((data: any) => {
|