Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Adds a few examples

Coppleb72feec5406a
diff --git a/web/sidebar_spec_supabase.js b/web/sidebar_spec_supabase.js
index bbac4ce6eba..4d354586704 100644
--- a/web/sidebar_spec_supabase.js
+++ b/web/sidebar_spec_supabase.js
@@ -18,6 +18,12 @@ module.exports = {
items: ['reference/javascript/auth-api-createuser', 'reference/javascript/auth-api-deleteuser', 'reference/javascript/auth-api-generatelink', 'reference/javascript/auth-api-inviteuserbyemail', 'reference/javascript/auth-api-sendmobileotp', 'reference/javascript/auth-api-updateuserbyid'],
collapsed: true,
},
+ {
+ type: 'category',
+ label: 'Functions',
+ items: ['reference/javascript/invoke'],
+ collapsed: true,
+ },
{
type: 'category',
label: 'Database',
diff --git a/web/spec/supabase.yml b/web/spec/supabase.yml
index 3f4a9e22b17..e1b98d5d2c4 100644
--- a/web/spec/supabase.yml
+++ b/web/spec/supabase.yml
@@ -138,6 +138,9 @@ info:
- auth.api.inviteUserByEmail()
- auth.api.sendMobileOTP()
- auth.api.updateUserById()
+ - name: 'Functions'
+ items:
+ - invoke()
- name: 'Database'
items:
- select()
@@ -965,6 +968,45 @@ pages:
{ phone_confirm: true }
)
```
+ invoke():
+ title: 'invoke()'
+ description: |
+ Invokes a Supabase Function. See the [guide](/docs/guides/api) for details on writing Functions.
+ $ref: '@supabase/functions-js.FunctionsClient.invoke'
+ notes: |
+ - Requires an Authorization header.
+ - Invoke params generally match the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) spec.
+ examples:
+ - name: Basic invocation.
+ isSpotlight: true
+ js: |
+ ```js
+ const { data: user, error } = await supabase.functions.invoke('hello', {
+ body: { foo: 'bar' }
+ })
+ ```
+ - name: Specifying response type.
+ description: |
+ By default, `invoke()` will parse the response as JSON. You can parse the response in the following formats: `json`, `blob`, `text`, and `arrayBuffer`.
+ isSpotlight: true
+ js: |
+ ```js
+ const { data: user, error } = await supabase.functions.invoke('hello', {
+ responseType: 'text',
+ body: { foo: 'bar' }
+ })
+ ```
+ - name: Parsing custom headers.
+ description: |
+ Any `headers` will be passed through to the function. A common pattern is to pass a logged-in user's JWT token as an Authorization header.
+ isSpotlight: true
+ js: |
+ ```js
+ const { data: user, error } = await supabase.functions.invoke('hello', {
+ headers: { Authorization: 'Bearer ${supabase.auth.session()?.access_token}' },
+ body: { foo: 'bar' }
+ })
+ ```
select():
title: 'Fetch data: select()'