Fetcher class
HTTP client for the browser, Node or React Native. Created by
AltogicClient
during initialization. The client library uses
cross-fetch under the hood to
make requests to you app's execution environment.
When creating the client if apiKey
is specified in ClientOptions
,
Fetcher adds the provided apiKey to an Authorization header and sends
it in all RESTful API requests to your backend app.
Similarly, if there is an active user session, Fetcher also adds the session token to a Session header and sends it in all RESTful API requests to your backend app.
Constructors
Properties
- apiClient ↔ AltogicClient
-
Reference to the Altogic client object
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
-
headers
↔ Map<
String, String> -
The default headers that will be sent in each RESTful API request to
the execution environment
getter/setter pair
- restUrl ↔ String
-
The base URL that will be prepended to all RESTful API calls
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- session ↔ Session?
-
The user session information. After the user is signed in using its app
credentials or any Oauth2 provider credentials and if the session is
created for this sign in then the user session information is stored in
this field. If a session is available then the session token is added to
the default headers of the Fetcher
getter/setter pair
Methods
-
clearSession(
) → void - Clears the session info of the user from the Fetcher. Basically removes the Session header from the default request headers until a new session value is provided.
-
delete<
T> (String path, {Object? body, Map< String, dynamic> ? query, Map<String, dynamic> ? headers, ResolveType resolveType = ResolveType.json}) → Future<APIResponse< T> > - Makes a DELETE request to backend app execution environment.
-
get<
T> (String path, {Map< String, dynamic> ? query = const {}, Map<String, dynamic> ? headers = const {}, ResolveType resolveType = ResolveType.json}) → Future<APIResponse< T> > - Makes a GET request to backend app execution environment.
-
getBaseUrl(
) → String - Returns the api base url string.
-
getClientKey(
) → String? - Returns the client key
-
getSessionToken(
) → String? - Returns the session token
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
post<
T> (String path, {Object? body, Map< String, dynamic> ? query, Map<String, dynamic> ? headers, ResolveType resolveType = ResolveType.json}) → Future<APIResponse< T> > - Makes a POST request to backend app execution environment.
-
put<
T> (String path, {Object? body, Map< String, dynamic> ? query, Map<String, dynamic> ? headers, ResolveType resolveType = ResolveType.json}) → Future<APIResponse< T> > - Makes a PUT request to backend app execution environment.
-
setSession(
Session session, User? user) → void - Sets the session of the user that will be used by Fetcher. Adds the new session token to the Session request header.
-
toString(
) → String -
A string representation of this object.
inherited
-
upload<
T> (String path, Object body, String fileName, String contentType, {Map< String, dynamic> ? query, Map<String, dynamic> ? headers, void onProgress(int loaded, int total, double percent)?}) → Future<APIResponse< T> > - Uploads a file object instead of fetcher in order to track upload progress and call a callback function.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited