Response.variables.readJsonWithStandardSchemaV1
fx-fetch / Response / readJsonWithStandardSchemaV1
Variable: readJsonWithStandardSchemaV1()
Section titled “Variable: readJsonWithStandardSchemaV1()”
constreadJsonWithStandardSchemaV1: {<A,I>(response,schema):Effect<A,MalformedJsonError|ParseError,never>; <A,I>(schema): (response) =>Effect<A,MalformedJsonError|ParseError,never>; }
Defined in: packages/fx-fetch/src/Response/readJsonWithStandardSchemaV1.ts:81
Reads a JSON response with the given standard schema.
Call Signature
Section titled “Call Signature”<
A,I>(response,schema):Effect<A,MalformedJsonError|ParseError,never>
Reads a JSON response with the given standard schema.
Type Parameters
Section titled “Type Parameters”A
I
Parameters
Section titled “Parameters”response
Section titled “response”schema
Section titled “schema”StandardSchemaV1<I, A>
Returns
Section titled “Returns”Effect<A, MalformedJsonError | ParseError, never>
Example
Section titled “Example”import { Response } from 'fx-fetch';import { Effect } from 'effect';import { z } from 'zod'; // Or any other schema library compatible with Standard Schema
const UserSchema = z.object({ name: z.string(), age: z.number()});
const response = Response.unsafeMake({ ok: true, status: 200, statusText: '200 OK', type: 'default', url: 'https://api.example.com', body: '{"name":"Alice","age":25}'});
const userEffect = Response.readJsonWithStandardSchemaV1(response, UserSchema);https://standardschema.dev/schema
1.1.0
Call Signature
Section titled “Call Signature”<
A,I>(schema): (response) =>Effect<A,MalformedJsonError|ParseError,never>
Reads a JSON response with the given standard schema.
Type Parameters
Section titled “Type Parameters”A
I
Parameters
Section titled “Parameters”schema
Section titled “schema”StandardSchemaV1<I, A>
Returns
Section titled “Returns”(
response):Effect<A,MalformedJsonError|ParseError,never>
Parameters
Section titled “Parameters”response
Section titled “response”Returns
Section titled “Returns”Effect<A, MalformedJsonError | ParseError, never>
Example
Section titled “Example”import { Response } from 'fx-fetch';import { Effect, pipe } from 'effect';import { z } from 'zod'; // Or any other schema library compatible with Standard Schema
const UserSchema = z.object({ name: z.string(), age: z.number()});
const response = Response.unsafeMake({ ok: true, status: 200, statusText: '200 OK', type: 'default', url: 'https://api.example.com', body: '{"name":"Alice","age":25}'});
const userEffect = pipe( response, Response.readJsonWithStandardSchemaV1(UserSchema));https://standardschema.dev/schema
1.1.0
Example
Section titled “Example”import { Response } from 'fx-fetch';import { Effect } from 'effect';import { z } from 'zod'; // Or any other schema library compatible with Standard Schema
const UserSchema = z.object({ name: z.string(), age: z.number()});
const response = Response.unsafeMake({ ok: true, status: 200, statusText: '200 OK', type: 'default', url: 'https://api.example.com', body: '{"name":"Alice","age":25}'});
// Data-firstconst userEffect1 = Response.readJsonWithStandardSchemaV1(response, UserSchema);
// Data-last (pipeable)const userEffect2 = pipe( response, Response.readJsonWithStandardSchemaV1(UserSchema));https://standardschema.dev/schema
1.1.0