Skip to content

Commit 1680fe4

Browse files
committed
docs: remove net._http_collect_response usage
The _http_collect_response was never meant to be used by end users. It only was meant as an internal function for testing. Why? Because it uses an endless loop (net._await_response) which is not safe when running inside a transaction. Previously it was removed from https://supabase.com/docs/guides/database/extensions/pg_net For the same reason. If there's a need for sync requests, the current recommendation is to use pgsql-http.
1 parent 7babfd6 commit 1680fe4

File tree

1 file changed

+2
-42
lines changed

1 file changed

+2
-42
lines changed

README.md

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -166,43 +166,6 @@ After saving the file, you can execute `SELECT pg_reload_conf()` to update _post
166166

167167
# Requests API
168168

169-
## Monitoring Requests
170-
171-
When you call a request function (http_get, http_post, http_delete), the function will return a request_id immediately. You can use this request_id with the net.\_http_collect_response function to check the results of your request. This function returns a custom type \_net.http_response_result\* that has three columns:
172-
173-
1. **response**: This is an aggregate of the response's status_code (integer), headers (JSONB), and body (text).
174-
2. **status**: This value indicates the execution status of the request itself, which can be either 'PENDING', 'SUCCESS', or 'ERROR'. It's important not to confuse this status with the HTTP status code of the response (like 200 for 'OK', 404 for 'Not Found', etc.) that is found in the response column
175-
3. **message**: This contains the response's message as text.
176-
177-
#### Observing a Request's Response
178-
179-
```sql
180-
SELECT
181-
message,
182-
response,
183-
status
184-
FROM
185-
net._http_collect_response(<response_id>);
186-
```
187-
188-
> WARNING: Although the status column can be 'PENDING', 'SUCCESS', or 'ERROR', there is a bug that makes all 'PENDING' requests displayed as 'ERROR'.
189-
190-
The individual values within the response column can be extracted as shown in the following SQL query:
191-
192-
#### Extracting response values
193-
194-
```sql
195-
SELECT
196-
*,
197-
(response).status_code,
198-
(response).headers,
199-
(response).body
200-
-- Individual headers and values from the body can be extracted
201-
(((response).body::JSON)->'key-from-json-body') AS some_value
202-
FROM
203-
net._http_collect_response(<request_id>);
204-
```
205-
206169
## GET requests
207170

208171
### net.http_get function signature
@@ -241,11 +204,8 @@ SELECT net.http_get (
241204
> NOTE: You can view the response with the following query:
242205
>
243206
> ```sql
244-
> SELECT
245-
> *,
246-
> ((response).body::JSON)->'args' AS args
247-
> FROM
248-
> net._http_collect_response(<response_id>);
207+
> SELECT *
208+
> FROM net._http_response;
249209
> ```
250210
251211
#### Calling an API with URL encoded params

0 commit comments

Comments
 (0)