Skip to content

arkemishub/clientjs

Repository files navigation

@arkejs/client

Client

License

An isomorphic JavaScript client for Arke backend connection

Usage

First of all, you need to install the library:

npm install @arkejs/client
pnpm install @arkejs/client

Then you're able to import the library and establish the connection with the database:

import Client from '@arkejs/client'

// Create a single arke js for interacting with your server
const client = new Client({ 
    serverUrl: 'http://localhost:4000',
    project: 'PROJECT_NAME',
})

client.arke.get('my_arke').then(
  res => console.log(res.data),
  err => console.error(err.response.data)
)

When you initialize the client you can define custom methods to get the Auth session:

const client = new Client({
    serverUrl: 'http://localhost:4000',
    project: 'PROJECT_NAME',
    getSession: async () => {
      const session = await AsyncStorage.getItem('@session');
      return session;
    },
    setSession: async session => {
      await AsyncStorage.setItem('@session', JSON.stringify(session.content));
    },
  });