Skip to main content

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

new PreferenceService()

new PreferenceService(): PreferenceService

Returns

PreferenceService

Methods

getAllPreferences()

static getAllPreferences(config?): Promise <SCPaginatedResponse<SCPreferenceType>>

Parameters

ParameterType
config?AxiosRequestConfig<any>

Returns

Promise <SCPaginatedResponse<SCPreferenceType>>

Source

services/preference/index.ts:112


getSpecificPreference()

static getSpecificPreference(id, config?): Promise<SCPreferenceType>

Parameters

ParameterType
idstring | number
config?AxiosRequestConfig<any>

Returns

Promise<SCPreferenceType>

Source

services/preference/index.ts:126


searchPreferences()

static searchPreferences(search?, section?, keys?, ordering?, config?): Promise <SCPaginatedResponse<SCPreferenceType>>

Parameters

ParameterType
search?string
section?string
keys?string
ordering?string
config?AxiosRequestConfig<any>

Returns

Promise <SCPaginatedResponse<SCPreferenceType>>

Source

services/preference/index.ts:116


updatePreferences()

static updatePreferences(data, config?): Promise<SCPreferenceType | SCPreferenceType[]>

Parameters

ParameterType
dataany
config?AxiosRequestConfig<any>

Returns

Promise<SCPreferenceType | SCPreferenceType[]>

Source

services/preference/index.ts:130