Configure the HttpClient in the Model
See original GitHub issueIs 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 https://github.com/DavidDuwaer/Coloquent/issues/37.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7 (7 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think the best would be to define
httpClient
asabstract static httpClient: HttpClient
, but this seems not possible in TypeScript.The PR haa been merged, it’s available with the version
3.0.1-beta
.