// Create a program that derives and uses the client
const program = Effect.gen(function* () {
// Derive the client
const client = yield* HttpApiClient.make(MyApi, {
baseUrl: "http://localhost:3000"
})
// Call the "hello-world" endpoint
const hello = yield* client.Greetings["hello-world"]()
console.log(hello)
})
// Provide a Fetch-based HTTP client and run the program
Effect.runFork(program.pipe(Effect.provide(FetchHttpClient.layer)))
// Output: Hello, World!
// Create a program that derives and uses the client
const program = Effect.gen(function* () {
// Derive the client
const client = yield* HttpApiClient.make(MyApi, {
baseUrl: "http://localhost:3000"
})
// Call the "hello-world" endpoint
const hello = yield* client.Greetings["hello-world"]()
console.log(hello)
})
// Provide a Fetch-based HTTP client and run the program
Effect.runFork(program.pipe(Effect.provide(FetchHttpClient.layer)))
// Output: Hello, World!