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
1017 B
1017 B
HTTP Calls
Each cloud function provides an API endpoint that can be called from anywhere capable of making HTTP requests.
Using axios for the call
Here is a simple example of using axios in the frontend to make a request to a cloud function.
// get request
import axios from 'axios';
const { data } = await axios({
url: "<FunctionURL>",
method: "get",
});
console.log(data);
// post request
import axios from 'axios';
const { data } = await axios({
url: "<FunctionURL>",
method: "post",
data: {
name: 'Jack'
}
});
console.log(data);
curl Invocation
You can also use curl to invoke cloud functions.
GET request
curl <FunctionURL>?query=hello&limit=10 \
-H "Authorization: Bearer abc123" \
-H "Content-Type: application/json"
POST request
curl -X POST <FunctionURL> \
-H "Content-Type: application/json" \
-d '{"name": "John", "age": 30}'
