Skip to content

Commit

Permalink
v.0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
behzodfaiziev committed Nov 18, 2024
1 parent 24a50e3 commit 04c1b62
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [0.7.0]

- added `withCredentials` and `cancelToken` as optional parameters in constructor
- exported

## [0.6.2]

- updated github actions to use strict check on formatting
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next-netkit",
"version": "0.6.2",
"version": "0.7.0",
"description": "Network manager",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
Expand Down
19 changes: 15 additions & 4 deletions src/network-manager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios";
import axios from "axios";
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse, CancelToken } from "axios";
import { injectable } from "inversify";

import { INetworkManager } from "./network-manager.interface";
Expand All @@ -13,7 +12,9 @@ interface NetworkManagerParams {
testMode: boolean;
baseOptions: AxiosRequestConfig;
errorParams: NetworkErrorParams;
cancelToken?: CancelToken;
isClientSideWeb: boolean;
withCredentials?: boolean;
}

@injectable()
Expand Down Expand Up @@ -41,16 +42,26 @@ class NetworkManager implements INetworkManager {

private axiosInstance: AxiosInstance;

constructor({ baseUrl, devBaseUrl, testMode, baseOptions, errorParams, isClientSideWeb }: NetworkManagerParams) {
constructor({
baseUrl,
devBaseUrl,
testMode,
baseOptions,
errorParams,
isClientSideWeb,
withCredentials = true,
cancelToken,
}: NetworkManagerParams) {
this.baseUrl = baseUrl;
this.devBaseUrl = devBaseUrl;
this.testMode = testMode;
this.baseOptions = baseOptions;
this.errorParams = errorParams;
this.isClientSide = isClientSideWeb;

this.axiosInstance = axios.create({
baseURL: this.testMode ? this.devBaseUrl : this.baseUrl,
withCredentials: withCredentials,
cancelToken: cancelToken,
// Additional config options
});
this.setTokensFromLocalStorage();
Expand Down

0 comments on commit 04c1b62

Please sign in to comment.