shApi

This is used to make api requests to the backend using axiosopen in new window

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: string

  • Required: true

  • Example: users

  • Details:

    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: string

  • Required: true

  • Example: users/add

  • Details:

    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

Last Updated:
Contributors: silah