.default

Defaults controller is used to set and get key-value pairs used across the application.

TIP: The value can be an object.

.setDefault()

To set the value of a key. Optionally, pass the parent param if the key was set under a different parent.

When setting values, they are stringified before adding it in the server.

Input

SetDefaultParams

property

type

required

description

key

string

yes

Key of the value required.

value

DefaultValueTypes

yes

The value to assign to the key. Can be an object.

parent

string

no

Can specify the parent if the key is duplicated under a different parent. By default uses '__default' as parent.

Output

DefaultValueTypes

Example

async-await

const response = await renovationInstance.defaults.setDefault({
key: "disableSubmission",
value: false
});
// response.data => "false"
console.log("Response: ", response.data);

Classic Promise

renovationInstance.defaults
.setDefault({
key: "disableSubmission",
value: false
})
// response.data => "false"
.then(response => console.log("Response: ", response.data));

.getDefault() ★

To get the value of a key. Optionally, pass the parent param if the key was set under a different parent.

The values are parsed from string when retrieved from the backend.

Input parameters

GetDefaultParams

property

type

required

description

key

string

yes

Key of the value required.

parent

string

no

Can specify the parent if the key is duplicated under a different parent. By default uses '__default' as parent.

Output

unknown

The output since the value can be of many types based on JSON.parse()

Example

async-await

const value = await renovationInstance.defaults.getDefault({
key: "disableSubmission",
parent: "specific"
});
// value.data => false
console.log("Value: ", value.data);

Classic Promise

renovationInstance.defaults
.getDefault({
key: "disableSubmission",
parent: "specific"
})
// value.data => false
.then(value => console.log("Value: ", value.data));

In case the key is not found, a successful empty response is returned.

{
"success": true,
"httpCode": 200
}