Base44: functions.fetch() for Streaming and Raw HTTP Access
Base44 has added a functions.fetch() method to its SDK, giving developers direct, low-level HTTP access to backend functions. Unlike the existing invoke() method, functions.fetch() returns a native Response object, unlocking support for streaming responses (SSE, chunked text, NDJSON), custom HTTP methods (PUT, PATCH, DELETE), and binary data downloads. Authentication headers are injected automatically, so developers gain raw HTTP power without sacrificing the security conveniences the SDK provides.
Sources & Mentions
2 external resources covering this update
Overview
Base44 has expanded its JavaScript SDK with a new functions.fetch() method, offering developers a lower-level, more flexible way to interact with backend functions. Where functions.invoke() abstracts the HTTP call behind a clean async interface returning parsed JSON, functions.fetch() exposes the underlying Response object directly — bringing the full power of the Fetch API to Base44 backend interactions.
Why functions.fetch() Was Needed
The existing invoke() method covers the vast majority of use cases: send a request, receive a JSON response. However, certain scenarios require more control than that abstraction allows. Streaming server-sent events from a backend function, downloading binary files, or issuing RESTful HTTP methods like PUT or DELETE were either impossible or required awkward workarounds. functions.fetch() closes that gap by returning the raw Response object that the browser's Fetch API provides, letting developers interact with it however they need.
How It Works
Streaming Responses
With functions.fetch(), developers can consume streaming responses incrementally. Backend functions that emit Server-Sent Events (SSE), chunked text, or Newline-Delimited JSON (NDJSON) can now be read in real time on the frontend. The response body is accessible as a readable stream, enabling progressive rendering of AI-generated text, live log output, or other continuous data feeds.
Custom HTTP Methods
By default, functions.invoke() issues a POST request. functions.fetch() accepts an options object that mirrors the standard Fetch API init parameter, meaning developers can specify method: 'PUT', method: 'PATCH', or method: 'DELETE' when the backend function's semantics call for it. This allows Base44 backend functions to more naturally express RESTful resource operations.
Binary Data Downloads
The raw Response object returned by functions.fetch() supports .blob(), .arrayBuffer(), and other body-reading methods that invoke() does not expose. This makes it straightforward to download PDFs, images, exports, or other binary payloads directly from a backend function and save them to the user's device.
Raw Response Access
Beyond the body, functions.fetch() gives access to the full HTTP response: status codes, headers, and the ability to inspect or branch on response metadata before consuming the body. This is useful for error handling patterns that go beyond simple exception catching, or for reading custom headers returned by a function.
Automatic Authentication
Despite the lower-level interface, functions.fetch() does not require developers to manage authentication manually. Base44 still injects the current user's session credentials into the request headers before it is dispatched, preserving the same security convenience that invoke() provides. Developers get raw HTTP power without giving up the SDK's auth layer.
When to Use Each Method
functions.invoke() remains the recommended default for standard request/response flows where the result is JSON. It is simpler, more readable, and handles the most common pattern without boilerplate. functions.fetch() is an intentional escape hatch for the cases where that abstraction is insufficient — streaming, binary downloads, non-POST methods, or situations where response metadata matters. Choosing between them follows the same principle as choosing between a high-level API and its underlying primitive: use the abstraction when it fits, and reach for the primitive when it does not.