Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Configure the HttpClient in the Model

See original GitHub issue

Is there a way to configure the HttpClient to use for a Model?

I would like to use a specific Axios instance that uses custom interceptors.

The AxiosHttpClient is not exposed, but maybe it should be.

Maybe something like:

import customAxiosInstance from './path/to/axios/custom/instance'
import { Model, HttpClient, AxiosHttpClient } from 'coloquent'

export default abstract class ApplicationModel extends Model {
  public getHttpClient(): HttpClient {
    return new AxiosHttpClient(Api)
  // ...

This might be related to

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

masterTcommented, Jan 8, 2022

I think the best would be to define httpClient as abstract static httpClient: HttpClient, but this seems not possible in TypeScript.

masterTcommented, Feb 2, 2022

The PR haa been merged, it’s available with the version 3.0.1-beta.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Make HTTP requests using IHttpClientFactory in ASP.NET Core
Provides a central location for naming and configuring logical HttpClient instances. For example, a client named github could be registered and ...
Read more >
HTTP Client Configuration - Microsoft Open Source
HTTP client configuration is based on HttpClientConfig and represented by the following configuration schema. ... Configuration settings: ... If you're using an ...
Read more >
Advanced Apache HttpClient Configuration - Baeldung
We can configure the HttpClient to send each request via proxy, together with the Authorization header that will be used to perform an ......
Read more >
C# HttpClient - creating HTTP requests with ... - ZetCode
C# HttpClient tutorial shows how to create HTTP requests with HttpClient in C#. In the examples, we create simple GET, HEAD, ...
Read more >
Best way to handle HttpClient inside Model class in C# - Stack ...
Store the external service URL in configuration and use DI to pass IConfiguration to model class. Then use HttpClient to interact with the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found