You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/api/api.ts
+27-5Lines changed: 27 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,10 @@ type RawResponseType<T> = T extends Date
34
34
}
35
35
: T;
36
36
37
+
exportinterfaceAbortable{
38
+
abort(): void;
39
+
}
40
+
37
41
/**
38
42
* The response handler is a class that allows you to handle the response of a request to the API.
39
43
* It allows you to define what to do when the request is successful, when it returns an error (an API error), when it fails (a request error), or when it returns a specific status code or specific failure.
@@ -58,18 +62,22 @@ type RawResponseType<T> = T extends Date
returnthisasunknownasResponseHandler<T,{[KinS|keyofR]: KextendsS ? O : R[K]}>;
97
105
}
98
106
107
+
/**
108
+
* Aborts the request that produces this reponse.
109
+
* Fires ResponseError.timeout handler or falls back to failure handler.
110
+
*/
111
+
abort(){
112
+
this.abortController.abort();
113
+
}
114
+
99
115
asynctoPromise(): Promise<
100
116
Awaited<Exclude<R[keyofR],void|undefined>|(undefinedextendsR[keyofR] ? null : never)>// For some reason, undefined extends void. See https://github.com/ungdev/etu-utt-front/pull/28/files#r2357325209, Alban got the explanation
101
117
>{
@@ -140,6 +156,7 @@ async function internalRequestAPI<RequestType>(
0 commit comments