Skip to content

Configuration

import { Aside } from ‘@astrojs/starlight/components’;

Set how long the library waits for a response before giving up. The default is 10 000 ms (10 seconds).

pb.setTimeout(5000); // 5 seconds
pb.setTimeout(30000); // 30 seconds for slow connections

Call setTimeout() before making requests. It affects all subsequent requests.

By default, TLS certificate verification is disabled (setInsecureTLS(true)). This lets you connect to PocketBase instances with self-signed or development certificates without extra setup.

pb.setInsecureTLS(true); // skip verification (default) — for dev / self-signed certs
pb.setInsecureTLS(false); // verify certificate — for production with a valid cert

Enable verbose output to Serial during development:

pb.setDebug(true);

When enabled, the library prints:

  • The full request URL
  • The HTTP status code
  • The raw response body

Example Serial output:

[PB] GET https://my-pb.com/api/collections/notes/records/abc123
[PB] Status: 200
[PB] Body: {"id":"abc123","title":"Hello","created":"2024-01-15 10:30:00.000Z"}

Use checkHealth() as a connectivity probe at device startup — it does not require a collection to be set:

PBResponse health = pb.checkHealth();
if (!health.ok) {
Serial.println("PocketBase unreachable, halting");
while (true) delay(1000);
}
Serial.println("Server healthy: " + health.body);
// Body: {"code":200,"message":"API is healthy."}
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500); Serial.print(".");
}
// 1. Configure before first request
pb.setTimeout(8000);
pb.setInsecureTLS(true); // adjust for your server
pb.setDebug(true); // remove for production
// 2. Verify connectivity
PBResponse health = pb.checkHealth();
if (!health.ok) {
Serial.println("Cannot reach PocketBase");
return;
}
// 3. Authenticate (if needed)
pb.collection("users").authWithPassword("user@example.com", "password");
// 4. Start your application logic
}