Repository navigation
v2.0.4
Built base for making and simulating data calls
In this release you have access to the function generators which enable you to simulate data calls as well as have live calls in your app when you import them into your app from the package.
This means you can do something like this
// Define the hook configuration
const hookConfig = {
name: "myFetchDataHook", // Specify a name for your hook
dataCallerType: "axios", // Set the DataCallerType to "axios"
method: "get", // Specify the HTTP method (default: "get")
url: "https://api.example.com/data", // Specify the URL
/** Other optional props below can be included depending on your use case */
requestData: { key: "value" }, // Include data to be sent in the request body (optional)
signal: undefined, // Specify the AbortSignal object for canceling requests (optional)
headers: { "Content-Type": "application/json" }, // Include HTTP headers (optional)
onUploadProgess: (e: ProgressEvent) => {
console.log("Upload Progress:", e.loaded);
}, // Include a function to handle upload progress (optional)
};
// Call the hook generator with the hook configuration
const { functions, loaders } = useFunctionGenerator(hookConfig);
const handleGetData = async () => {
try {
const result = await functions.takeAction();
console.log("Data:", result.payload);
} catch (error) {
console.error("Error:", error);
}
};
```javascript
Study the readme below to understand how to use this version properly. If you have any issues, kindly add them to this repo or fork the repo branch and raise a PR
[README.md](https://github.com/metrobuzz-com-ng/netwrap/files/14138237/README.md)
### Note
This will be removed once we move to version 3