Inicio port NOS
This commit is contained in:
29
packages/sim-consumidor-nos/infrastructure/NosHttpClient.ts
Normal file
29
packages/sim-consumidor-nos/infrastructure/NosHttpClient.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import axios, { AxiosInstance } from "axios";
|
||||
import { env } from "#config/env/env.js"
|
||||
|
||||
export class NosHttpClient {
|
||||
public client: AxiosInstance;
|
||||
|
||||
constructor(
|
||||
private baseURL: string,
|
||||
//private jwtManager: JWTProvider<any>
|
||||
) {
|
||||
this.client = axios.create({
|
||||
baseURL: baseURL
|
||||
})
|
||||
|
||||
// Interceptor para los headers fijos
|
||||
this.client.interceptors.request.use(
|
||||
async (config) => {
|
||||
// Configuracion especifica de NOS (El token simepre es el mismo?)
|
||||
const token = env.NOS_ACCESS_TOKEN;
|
||||
config.headers.Authorization = `Bearer ${token}`
|
||||
config.headers.set("content-type", "application/json")
|
||||
return config
|
||||
},
|
||||
(error) => Promise.reject(error)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user