laf/docs/en/guide/function/call-function-in-http.md
nightwhite 16cc16f61f
doc: add international English section (#1308)
* 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
2023-06-25 16:36:23 +08:00

1017 B

HTTP Calls

Each cloud function provides an API endpoint that can be called from anywhere capable of making HTTP requests.

function-url

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}'