Members
# static constant session
Exports all functionalities from "mx-api/session".
Methods
# static getAppUrl()
Root URL from which application is loaded, e.g. https://domain.com/mendixapp/
.
Example
getAppUrl();
# static login(params)
Tries to log in using a username.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
params |
Object
|
|||
username |
string
|
username to log in with |
||
password |
string
|
password to log in with |
||
useAuthToken |
boolean
|
<optional> |
false (web), true (native) | stay logged in until token expires, when useAuthToken is omitted, the default behavior of the requested profile is used |
reloadOnSuccess |
boolean
|
<optional> |
true | reload the page on successful login, if set to false, it allows you to handle success manually |
Example
// Example with useAuthToken set to true and reloadOnSuccess set to false
try {
await login({
username: "fred",
password: "fred's unguessable password",
useAuthToken: true,
reloadOnSuccess: false,
});
console.log("Successful login.");
// success handling
} catch (error) {
console.log("Login failed: ", error);
// error handling
}
# static logout()
Logs out the user and restarts the client.
Example
try {
await logout();
} catch (error) {
console.error('Logout failed: ', error);
}