PreferenceService
Preference service can be used in the following way:
1. Import the service from our library:
import {PreferenceService} from "@selfcommunity/api-services";
2. Create a function and put the service inside it!
The async function `getAllPreferences` will return the paginated list of preferences.
async getAllPreferences() {
return await PreferenceService.getAllPreferences();
}
In case of required `params`, just add them inside the brackets.
async getSpecificPreference(preferenceId) {
return await PreferenceService.getSpecificPreference(preferenceId);
}
If you need to customize the request, you can add optional config params (`AxiosRequestConfig` type).
1. Declare it(or declare them, it is possible to add multiple params)
const headers = headers: {Authorization: `Bearer ${yourToken}`}
2. Add it inside the brackets and pass it to the function, as shown in the previous example!
Constructors
Constructor
new PreferenceService():
PreferenceService
Returns
PreferenceService
Methods
getAllPreferences()
static
getAllPreferences(config?
):Promise
<SCPaginatedResponse
<SCPreferenceType
>>
Parameters
Parameter | Type |
---|---|
config? | AxiosRequestConfig |
Returns
Promise
<SCPaginatedResponse
<SCPreferenceType
>>
getSpecificPreference()
static
getSpecificPreference(id
,config?
):Promise
<SCPreferenceType
>
Parameters
Parameter | Type |
---|---|
id | string | number |
config? | AxiosRequestConfig |
Returns
Promise
<SCPreferenceType
>
searchPreferences()
static
searchPreferences(search?
,section?
,keys?
,ordering?
,config?
):Promise
<SCPaginatedResponse
<SCPreferenceType
>>
Parameters
Parameter | Type |
---|---|
search? | string |
section? | string |
keys? | string |
ordering? | string |
config? | AxiosRequestConfig |
Returns
Promise
<SCPaginatedResponse
<SCPreferenceType
>>
updatePreferences()
static
updatePreferences(data
,config?
):Promise
<SCPreferenceType
|SCPreferenceType
[]>
Parameters
Parameter | Type |
---|---|
data | any |
config? | AxiosRequestConfig |
Returns
Promise
<SCPreferenceType
| SCPreferenceType
[]>