Skip to content

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

fix: stringify body functions.invoke

thorwebdevc0b9726086ab
diff --git a/web/docs/guides/functions.mdx b/web/docs/guides/functions.mdx
index 092f4a82593..ce07d17a72d 100644
--- a/web/docs/guides/functions.mdx
+++ b/web/docs/guides/functions.mdx
@@ -13,10 +13,20 @@ const examples = [
href: 'https://github.com/supabase/supabase/tree/master/examples/edge-functions',
},
{
- name: 'With Stripe',
+ name: 'With CORS headers',
+ description: 'Send CORS headers for invoking from the browser.',
+ href: 'https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/browser-with-cors/index.ts',
+ },
+ {
+ name: 'React Native with Stripe',
description: 'Full example for using Supabase and Stripe, with Expo.',
href: 'https://github.com/supabase-community/expo-stripe-payments-with-supabase-functions',
},
+ {
+ name: 'Flutter with Stripe',
+ description: 'Full example for using Supabase and Stripe, with Flutter.',
+ href: 'https://github.com/supabase-community/flutter-stripe-payments-with-supabase-functions',
+ },
]
:::caution
diff --git a/web/spec/supabase.yml b/web/spec/supabase.yml
index 3559e7a2ec0..9c7afdee457 100644
--- a/web/spec/supabase.yml
+++ b/web/spec/supabase.yml
@@ -373,7 +373,7 @@ pages:
res.status(200).json(allOnlineUsers);
};
```
-
+
For more advance type-support, check out [`postgrest-js-tools`](https://github.com/mzalevski/postgrest-js-tools).
@@ -784,7 +784,7 @@ pages:
notes: |
- Requires a `service_role` key.
- This function should be called on a server. Never expose your `service_role` key in the browser.
- - If you do not provide the `email_confirm` and `phone_confirm` options to this function, both will default to false.
+ - If you do not provide the `email_confirm` and `phone_confirm` options to this function, both will default to false.
examples:
- name: Create a new user.
isSpotlight: true
@@ -985,14 +985,14 @@ pages:
$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.
+ - 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' }
+ body: JSON.stringify({ foo: 'bar' })
})
```
- name: Specifying response type.
@@ -1003,22 +1003,20 @@ pages:
```js
const { data: user, error } = await supabase.functions.invoke('hello', {
responseType: 'text',
- body: { foo: 'bar' }
+ body: JSON.stringify({ 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.
+ You can pass custom headers to your function. Note: supabase-js automatically passes the `Authorization` header with the signed in user's JWT.
isSpotlight: true
js: |
```js
const { data: user, error } = await supabase.functions.invoke('hello', {
headers: {
- Authorization: 'Bearer ${supabase.auth.session()?.access_token}'
+ "my-custom-header": 'my-custom-header-value'
},
- body: {
- foo: 'bar'
- }
+ body: JSON.stringify({ foo: 'bar' })
})
```
@@ -1061,10 +1059,10 @@ pages:
`)
```
note: |
- What about join tables
- If you're in a situation where your tables are **NOT** directly related, but instead are joined by a _join table_,
- you can still use the `select()` method to query the related data. The PostgREST engine detects the relationship automatically.
- For more details, [follow the link](https://postgrest.org/en/v9.0/api.html#embedding-through-join-tables).
+ What about join tables
+ If you're in a situation where your tables are **NOT** directly related, but instead are joined by a _join table_,
+ you can still use the `select()` method to query the related data. The PostgREST engine detects the relationship automatically.
+ For more details, [follow the link](https://postgrest.org/en/v9.0/api.html#embedding-through-join-tables).
- name: Query the same foreign table multiple times
description: |
Sometimes you will need to query the same foreign table twice.