mirror of
https://github.com/labring/laf.git
synced 2026-01-25 16:07:45 +00:00
* doc: add international English section * doc: del operator.md * doc: some old error * doc: fix path errors * doc: modify the default readme language * doc: Part of the internationalization of changes * doc: keep English readme * doc: delete readme_en.md
1.2 KiB
1.2 KiB
| title |
|---|
| Calling in the Client |
{{ $frontmatter.title }}
Once the cloud function is written and published, it can be called from the client using laf-client-sdk.
::: info Currently, the SDK only supports sending POST requests. :::
Installing the SDK in the Frontend Project
npm i laf-client-sdk
Initializing the cloud Object
import { Cloud } from "laf-client-sdk";
const cloud = new Cloud({
baseUrl: "https://APPID.laf.run", // Get APPID from the application list on the homepage
getAccessToken: () => "", // No authorization required here, leave it empty for now
})
Calling the Cloud Function
// The first argument here is the name of the cloud function, and the second argument is the data passed in, corresponding to ctx.body in the cloud function
const res = await cloud.invoke('get-user-info', { userid })
console.log(res) // The content returned by the cloud function is stored in the variable `res`
It's convenient, right? With just a simple configuration and one line of code, you can call the cloud function.
laf-client-sdk Detailed Documentation
View the detailed documentation: client-sdk