mirror of
https://github.com/labring/laf.git
synced 2026-01-18 16:03:17 +00:00
611 B
611 B
HTTP 调用
云函数每个云函数都提供了 API 地址,理论上我们可以在任何能发起 http 请求的地方调用云函数。
下面是用前端使用 axios 请求云函数的简单示例。
// get 请求
import axios from 'axios';
const { data } = await axios({
url: "<FunctionURL>",
method: "get",
});
console.log(data);
// post 请求
import axios from 'axios';
const { data } = await axios({
url: "<FunctionURL>",
method: "post",
data: {
name: 'Jack'
}
});
console.log(data);
