File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change 11import {
22 FetchHttpClient ,
33 HttpClient ,
4+ HttpClientRequest ,
45 HttpClientResponse ,
56} from "@effect/platform" ;
6- import { Effect } from "effect" ;
7+ import { Effect , flow } from "effect" ;
78import { Pokemon } from "../schemas" ;
89
9- export const main = HttpClient . get (
10- "https://pokeapi.co/api/v2/pokemon/squirtle"
11- ) . pipe (
10+ export const main = Effect . gen ( function * ( ) {
11+ const baseClient = yield * HttpClient . HttpClient ;
12+ const pokeApiClient = baseClient . pipe (
13+ HttpClient . mapRequest (
14+ flow (
15+ HttpClientRequest . acceptJson ,
16+ HttpClientRequest . prependUrl ( "https://pokeapi.co/api/v2" )
17+ )
18+ )
19+ ) ;
20+
21+ return yield * pokeApiClient . get ( "/pokemon/squirtle" ) ;
22+ } ) . pipe (
1223 Effect . flatMap ( HttpClientResponse . schemaBodyJson ( Pokemon ) ) ,
1324 Effect . scoped ,
1425 Effect . provide ( FetchHttpClient . layer )
You can’t perform that action at this time.
0 commit comments