Skip to content

Commit f9efd6e

Browse files
committed
feat: add PATCH command to fetch API for handling PATCH requests
1 parent 86e90ef commit f9efd6e

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

docs/api/fetch.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ Initiates a POST request to the specified URL with the given body. Returns a han
2626
webcc::FetchRequest post(webcc::string_view url, webcc::string_view body);
2727
```
2828

29+
### `patch`
30+
31+
Initiates a PATCH request to the specified URL with the given body. Returns a handle that identifies the request.
32+
33+
```cpp
34+
webcc::FetchRequest patch(webcc::string_view url, webcc::string_view body);
35+
```
36+
2937
## Events
3038
3139
Fetch operations are asynchronous. You must poll for events to receive the results.

schema.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ fetch|event|SUCCESS|handle(FetchRequest):id string:data
175175
fetch|event|ERROR|handle(FetchRequest):id string:error
176176
fetch|command|GET|get|string:url RET:handle(FetchRequest)|{ const id = (window.webcc_next_id = (window.webcc_next_id || 0) + 1); fetch(url).then(r => r.text().then(d => ({ ok: r.ok, status: r.status, statusText: r.statusText, data: d }))).then(res => { if(res.ok) push_event_fetch_SUCCESS(id, res.data); else push_event_fetch_ERROR(id, res.data && res.data.length ? res.data : (res.status + ' ' + res.statusText)); }).catch(e => push_event_fetch_ERROR(id, e.toString())); return id; }
177177
fetch|command|POST|post|string:url string:body RET:handle(FetchRequest)|{ const id = (window.webcc_next_id = (window.webcc_next_id || 0) + 1); fetch(url, { method: 'POST', body: body }).then(r => r.text().then(d => ({ ok: r.ok, status: r.status, statusText: r.statusText, data: d }))).then(res => { if(res.ok) push_event_fetch_SUCCESS(id, res.data); else push_event_fetch_ERROR(id, res.data && res.data.length ? res.data : (res.status + ' ' + res.statusText)); }).catch(e => push_event_fetch_ERROR(id, e.toString())); return id; }
178+
fetch|command|PATCH|patch|string:url string:body RET:handle(FetchRequest)|{ const id = (window.webcc_next_id = (window.webcc_next_id || 0) + 1); fetch(url, { method: 'PATCH', body: body }).then(r => r.text().then(d => ({ ok: r.ok, status: r.status, statusText: r.statusText, data: d }))).then(res => { if(res.ok) push_event_fetch_SUCCESS(id, res.data); else push_event_fetch_ERROR(id, res.data && res.data.length ? res.data : (res.status + ' ' + res.statusText)); }).catch(e => push_event_fetch_ERROR(id, e.toString())); return id; }
178179

179180
# ------------------------------------------------------------------------------
180181
# IMAGES

0 commit comments

Comments
 (0)