Effect CommunityEC
Effect Community16mo ago
5 replies
mabasic

Trouble Setting Headers on HttpClient After Upgrading to Effect 3.8.0 and @effect/platform 0.65.1

Hi guys, I have just upgraded to the latest version of Effect 3.8.0 and @effect/platform 0.65.1, and I am having trouble with setting headers on HttpClient.

import { FetchHttpClient, HttpClient, HttpClientRequest, HttpClientResponse } from "@effect/platform";
// ...

    return Effect.gen(function* () {
      const httpClient = (yield* HttpClient.HttpClient).pipe(
        HttpClient.filterStatusOk,
      );


      return yield* httpClient.get(feedUrl).pipe(
        // HttpClientRequest.acceptJson,
        // HttpClientRequest.setHeaders({
        //   "Accept-Language": "hr",
        // }),
        // HttpClientRequest.bearerToken(token),
      );
    }).pipe(Effect.scoped, Effect.provide(FetchHttpClient.layer));


none of the commented out code works for me.

I get this error in the editor (lsp):

The 'this' context of type 'Effect<HttpClientResponse, HttpClientError, Scope>' is not assignable to method's 'this' of type 'HttpClientRequest'.


Any hints?
Was this page helpful?