forked from ember-cli/ember-fetch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
412 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Checks if the given response represents an unauthorized request error | ||
*/ | ||
export declare function isUnauthorizedResponse(response: Response): boolean; | ||
/** | ||
* Checks if the given response represents a forbidden request error | ||
*/ | ||
export declare function isForbiddenResponse(response: Response): boolean; | ||
/** | ||
* Checks if the given response represents an invalid request error | ||
*/ | ||
export declare function isInvalidResponse(response: Response): boolean; | ||
/** | ||
* Checks if the given response represents a bad request error | ||
*/ | ||
export declare function isBadRequestResponse(response: Response): boolean; | ||
/** | ||
* Checks if the given response represents a "not found" error | ||
*/ | ||
export declare function isNotFoundResponse(response: Response): boolean; | ||
/** | ||
* Checks if the given response represents a "gone" error | ||
*/ | ||
export declare function isGoneResponse(response: Response): boolean; | ||
/** | ||
* Checks if the given error is an "abort" error | ||
*/ | ||
export declare function isAbortError(error: DOMException): boolean; | ||
/** | ||
* Checks if the given response represents a conflict error | ||
*/ | ||
export declare function isConflictResponse(response: Response): boolean; | ||
/** | ||
* Checks if the given response represents a server error | ||
*/ | ||
export declare function isServerErrorResponse(response: Response): boolean; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import Mix from '@ember/polyfills/types'; | ||
export type Nullable<T> = T | null | undefined; | ||
export type PlainObject<T = string | number | boolean> = { | ||
[key: string]: T | PlainObject<T> | PlainObject<T>[] | undefined | null; | ||
}; | ||
export type PlainHeaders = { | ||
[key: string]: string; | ||
}; | ||
export type Method = 'HEAD' | 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS'; | ||
export type AjaxOptions = { | ||
url: string; | ||
type: Method; | ||
data?: PlainObject | BodyInit; | ||
headers?: PlainHeaders; | ||
}; | ||
export type Credentials = 'omit' | 'same-origin' | 'include'; | ||
export type FetchOptions = Mix<AjaxOptions, { | ||
body?: BodyInit | null; | ||
method?: Method; | ||
credentials: Credentials; | ||
}>; | ||
export declare function isPlainObject(obj: any): obj is PlainObject; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/// <reference types="jquery" /> | ||
/** | ||
* Function that always attempts to parse the response as json, and if an error is thrown, | ||
* returns `undefined` if the response is successful and has a status code of 204 (No Content), | ||
* or 205 (Reset Content) or if the request method was 'HEAD', and the plain payload otherwise. | ||
*/ | ||
export default function determineBodyPromise(response: Response, requestData: JQueryAjaxSettings): Promise<object | string | undefined>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { FetchOptions, AjaxOptions } from 'ember-fetch/types'; | ||
/** | ||
* Helper function that translates the options passed to `jQuery.ajax` into a format that `fetch` expects. | ||
*/ | ||
export default function mungOptionsForFetch(options: AjaxOptions): FetchOptions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* Helper function that turns the data/body of a request into a query param string. | ||
* This is directly copied from jQuery.param. | ||
*/ | ||
export declare function serializeQueryParams(queryParamsObject: object | string): string; | ||
export default serializeQueryParams; |
Oops, something went wrong.