Skip to main content
Version: 3.x.x

Dispatching


Trigger request

We can execute queries using the built-in send() function or use React hooks.

import { postLogin } from "server/auth";

...

const handleLogin = async (values: {email: string, password: string}) => {
const [data, error, status] = await postLogin.setData(values).send();

if(data) {
// perform login
...
} else {
// handle error
...
}

}

...

Method send()

The send method takes full advantage of the potential of our features. We have implemented debouncing, retries, cancellation and offline awaiting solutions.

We can also dynamically transfer data to execute the request.

import { postData } from "server/auth";

...

const handleSend = async (values: ValuesType) => {
const [data, error, status] = await postData.send({
data: values,
params: { accountId: 2 },
queryParams: { param1: "test", param2: [1,2,3] }
})

if(data) {
// perform success action
...
} else {
// handle error
...
}

}

...