Skip to content

Commit

Permalink
added config in apiClient
Browse files Browse the repository at this point in the history
  • Loading branch information
dzgierski19 committed Jun 17, 2024
1 parent 5187b66 commit 9969fb4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/domains/weather/app/AxiosClient/AxiosClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ import * as dotenv from "dotenv";
dotenv.config();
import axios, { AxiosInstance } from "axios";
import { weatherApiConfig } from "./ConfigSchema";
import { configDataType } from "./ConfigTypes";

export class WeatherApiClient {
api: AxiosInstance;

constructor() {
constructor(private readonly config: configDataType) {
this.api = this.createAxiosInstance();
}

private createAxiosInstance(): AxiosInstance {
weatherApiConfig(this.config);
return axios.create({
baseURL: weatherApiConfig.baseUrl,
baseURL: this.config.baseUrl,
params: {
key: weatherApiConfig.apiKey,
key: this.config.apiKey,
},
});
}
}

//config w constructorze

0 comments on commit 9969fb4

Please sign in to comment.