
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
FetchXY is a lightweight and flexible HTTP client for TypeScript/JavaScript applications, providing a simple interface for making HTTP requests with built-in timeout handling, retries, and error management.
npm install fetch-xy
import FetchXY from 'fetch-xy';
const client = new FetchXY();
// Make a GET request
const response = await client.get('https://api.github.com/users/octocat');
console.log(response);
// Response will include:
// {
// data: { ... }, // Response data
// status: 200, // HTTP status code
// success: true, // Boolean indicating if status is 2xx
// headers: { ... }, // Response headers
// attempts: 0, // Number of retry attempts made
// retries: 0, // Total retries configured
// retryDelay: 1000 // Delay between retries in ms
// }
// Make a request with retries
const responseWithRetries = await client.get('https://api.github.com/users/octocat', {
retries: 3, // Retry up to 3 times
timeout: 5000, // Timeout after 5 seconds
retryDelay: 1000, // Wait 1 second between retries
retryIf: [408, 500] // Only retry on timeout or server error
});
const client = new FetchXY({
// Default timeout of 5 seconds
timeout: 5000,
// Retry failed requests up to 3 times
retries: 3,
// Wait 2 seconds between retries
retryDelay: 2000,
// Retry on specific HTTP status codes
retryIf: [408, 500, 502, 503, 504],
// Default headers
headers: {
'Authorization': 'Bearer your-token'
}
});
// Retry only on timeout (408) and server errors (500)
const client = new FetchXY({
retries: 2,
retryIf: [408, 500]
});
// Custom retry delay with specific status codes
const response = await client.get('https://api.example.com/data', {
retries: 3,
retryDelay: 1000, // 1 second between retries
retryIf: [503, 504] // Retry only on service unavailable
});
// Timeout configuration
const response = await client.post('https://api.example.com/data', {
timeout: 3000, // 3 second timeout
retries: 2, // Retry twice if timeout occurs
data: {
name: 'John Doe'
}
});
get(url, config)
post(url, config)
put(url, config)
delete(url, config)
patch(url, config)
git clone https://github.com/cardoso222/FetchXY.git
cd FetchXY
npm install
npm run build
npm test
Contributions are welcome! Here's how you can help:
git checkout -b feature/amazing-feature
)git commit -m 'Add some amazing feature'
)git push origin feature/amazing-feature
)This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions, please file an issue on the GitHub repository.
FAQs
A Fetch API wrapper with some extra features
The npm package fetch-xy receives a total of 4 weekly downloads. As such, fetch-xy popularity was classified as not popular.
We found that fetch-xy demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.