Skip to content

Commit

Permalink
updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
behzodfaiziev committed Nov 25, 2024
1 parent d3d592a commit 603d7e5
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,26 +262,15 @@ Create a module for the network manager using `Inversify`.
import { ContainerModule, interfaces } from "inversify";
import { INetworkManager, NetworkManager, NetworkErrorParams } from "next-netkit";

// Define error-handling parameters
const networkErrorParams: NetworkErrorParams = {
messageKey: "message",
statusCodeKey: "status",
couldNotParseError: "Could not parse error",
jsonIsEmptyError: "JSON is empty",
noInternetError: "No internet connection",
jsonNullError: "JSON is null",
jsonUnsupportedObjectError: "JSON is unsupported object",
notMapTypeError: "Not map type",
};

// Create NetworkManager instance
const networkManagerInstance = new NetworkManager(
"https://api.example.com",
"https://dev.example.com",
false,
{},
networkErrorParams
);
const networkManagerInstance = new NetworkManager({
baseUrl: "https://api.example.com", // Production base URL
devBaseUrl: "https://dev.example.com", // Development base URL
testMode: isTestMode, // Test mode: false (production), true (development)
baseOptions: {}, // Axios config options
errorParams: networkErrorParams, // Error parameters
withCredentials: true,
refreshTokenPath: "api/auth/refresh-token",
});

// Create a network container module
const networkContainer = new ContainerModule((bind: interfaces.Bind) => {
Expand Down

0 comments on commit 603d7e5

Please sign in to comment.