Skip to Content
Calls

Path and query parameters

Fill in a path's parameters and build a query.

Fill in a path's :name parameters from params, and build the query string from a plain query object.

Fill in path parameters and a query

The following calls fill in an :id parameter, and send a query with a number, a repeated key and a dropped value:

import * as  from "effect/Schema";

import type {  } from "@monarcode/effetch";

declare const : .;

const  = .({ : ., : . });

// GET /todos/1
export const  = .("/todos/:id", { : { : 1 }, :  });

// GET /todos?page=1&tags=work&tags=home
export const  = .("/todos", {
  : { : 1, : ["work", "home"], :  },
  : .(),
});

Path parameters

Every :name in a path is a parameter, filled in from params. When a path has parameters, params is required, with exactly those names, and when it has none, params isn't allowed. Effetch URI-encodes the values for you.

Query parameters

query is a plain object. Arrays repeat the key, and null and undefined are dropped, so you can pass optional filters as they are.

With Effect 4.1 or later, a value can also be Redacted, such as Redacted.make(apiKey): it's sent as its value, and Effect keeps it out of its own logs and traces.

To type an endpoint's query and send values such as dates, give the endpoint a schema for it. See Typed query parameters.

What's next

On this page