Fetch with authentication and exponential back-off
- Source:
Members
-
<private, static, constant> _AUTH_HEADER :string
-
Authorization header
Type:
- string
- Source:
-
<private, static, constant> _BEARER :string
-
Bearer parameter for authorized call
Type:
- string
- Source:
-
<private, static, constant> _CONFIG :Chrome.Http.Config
-
Configuration object
Type:
- Source:
-
<private, static, constant> _DELAY
-
Delay multiplier for exponential back-off
- Source:
-
<private, static, constant> _MAX_RETRIES :int
-
Max retries on 500 errors
Type:
- int
- Source:
Methods
-
<private, static> _doIt(url, opts, conf) → {Promise.<JSON>}
-
Do a server request
Parameters:
Name Type Description urlstring server request
optsObject fetch options
confChrome.Http.Config configuration
- Source:
Returns:
response from server
- Type
- Promise.<JSON>
-
<private, static> _fetch(url, opts, conf, attempt) → {Promise.<JSON>}
-
Perform fetch, optionally using authorization and exponential back-off
Parameters:
Name Type Description urlstring server request
optsObject fetch options
confChrome.Http.Config configuration
attemptint the retry attempt we are on
- Source:
Returns:
response from server
- Type
- Promise.<JSON>
-
<private, static> _getAuthToken(isAuth, interactive) → {Promise.<string>}
-
Get authorization token
Parameters:
Name Type Description isAuthboolean if true, authorization required
interactiveboolean if true, user initiated
- Source:
Returns:
auth token
- Type
- Promise.<string>
-
<private, static> _getError(response) → {Error}
-
Get Error message
Parameters:
Name Type Description responseChrome.Http.Response server response
- Source:
Returns:
- Type
- Error
-
<private, static> _processResponse(response, url, opts, conf, attempt) → {Promise.<JSON>}
-
Check response and act accordingly
Parameters:
Name Type Description responseChrome.Http.Response server response
urlstring server
optsObject fetch options
confChrome.Http.Config configuration
attemptint the retry attempt we are on
- Source:
Returns:
response from server
- Type
- Promise.<JSON>
-
<private, static> _retry(url, opts, conf, attempt) → {Promise.<JSON>}
-
Retry authorized fetch with exponential back-off
Parameters:
Name Type Description urlstring server request
optsObject fetch options
confChrome.Http.Config configuration
attemptint the retry attempt we are on
- Source:
Returns:
response from server
- Type
- Promise.<JSON>
-
<private, static> _retryToken(url, opts, conf, attempt) → {Promise.<JSON>}
-
Retry fetch after removing cached auth token
Parameters:
Name Type Description urlstring server request
optsObject fetch options
confChrome.Http.Config configuration
attemptint the retry attempt we are on
- Source:
Returns:
response from server
- Type
- Promise.<JSON>
-
<static> doGet(url [, conf]) → {Promise.<JSON>}
-
Perform GET request
Parameters:
Name Type Argument Default Description urlstring server request
confChrome.Http.Config <optional>
null configuration
- Source:
Returns:
response from server
- Type
- Promise.<JSON>
-
<static> doPost(url [, conf]) → {Promise.<JSON>}
-
Perform POST request
Parameters:
Name Type Argument Default Description urlstring server request
confChrome.Http.Config <optional>
null configuration
- Source:
Returns:
response from server
- Type
- Promise.<JSON>
Type Definitions
-
Config
-
Http configuration
Type:
- Object
- Source:
Properties:
Name Type Argument Default Description isAuthboolean <optional>
false if true, authorization required
retryTokenboolean <optional>
false if true, retry with new token
interactiveboolean <optional>
false user initiated, if true
tokenstring <optional>
<nullable>
null auth token
backoffboolean <optional>
true if true, do exponential back-off
maxRetriesint <optional>
_MAX_ATTEMPTS max retries
-
Response
-
Http response
Type:
- Object
- Source:
Properties:
Name Type Description okboolean success flag
jsonfunction returned data as JSON
statusint HTTP response code
statusTextstring HTTP response message