Skip to content

Interface: FpApi

Defined in: fp-api.d.ts:488

The Fetchpier scripting API — the only global exposed to pre-request and post-response scripts besides console and a whitelisted subset of ECMAScript built-ins.

Available in two phases:

  • pre-request (runs before the HTTP fetch): fp.request is mutable, fp.response is undefined.
  • post-response (runs after the fetch): fp.response is available, mutations to fp.request throw.
readonly environment: FpEnvironment;

Defined in: fp-api.d.ts:496

Persistent environment variables for the active environment.


readonly request: FpRequest;

Defined in: fp-api.d.ts:490

The outgoing HTTP request. Mutable in pre-request, read-only in post-response.


readonly optional response?: FpResponse;

Defined in: fp-api.d.ts:493

The HTTP response. Only defined in post-response scripts.


readonly variables: FpVariables;

Defined in: fp-api.d.ts:499

Ephemeral per-request variables shared between pre and post phases.

error(...args): void;

Defined in: fp-api.d.ts:532

Logs to the Scripts console at the error level.

ParameterType
…argsunknown[]

void


expect(value): ChaiExpect;

Defined in: fp-api.d.ts:523

Starts a fluent chai-like assertion on value.

ParameterType
valueunknown

ChaiExpect

fp.expect(user).to.have.property('email').that.is.a('string')

log(...args): void;

Defined in: fp-api.d.ts:526

Logs to the Scripts console at the log level.

ParameterType
…argsunknown[]

void


test(name, fn): void;

Defined in: fp-api.d.ts:515

Defines a named test. The callback must be synchronous; any error thrown (including fp.expect failures) marks the test as failed.

The result is surfaced in the Tests tab of the request pane.

ParameterTypeDescription
namestringHuman-readable test name shown in the UI.
fn() => voidSynchronous assertion block.

void

fp.test('status is 200', () => {
fp.expect(fp.response.status).to.equal(200)
})

warn(...args): void;

Defined in: fp-api.d.ts:529

Logs to the Scripts console at the warn level.

ParameterType
…argsunknown[]

void