shApi
This is used to make api requests to the backend using axios
Importing
import { shApis } from '@silahkosgei/sfrontend'
Methods
doGet
Makes a GET request to the backend api
shApis.doGet('users', { role: 'admin' }).then(res => {
users.value = res.data
})
Params
endpoint
Type:
stringRequired:
trueExample:
usersDetails:
This is the backend enpoint for the GET request
data
- Type:
object - Required:
false - Example
{ role: 'admin' }
Details
This will be the request parameters on the GET request
doPost
Makes a POST request to the backend api
shApis.doPost('users/add', {
name: 'John',
email: 'john@example.com',
age: 12
}
).then(res => {
users.value = res.data
})
Params
endpoint
Type:
stringRequired:
trueExample:
users/addDetails:
This is the backend enpoint to post the POST request
data
- Type:
object - Required:
false - Example
{
name: 'John',
email: 'john@example.com',
age: 12
}
Details
This will be post data to the backend endpoint