
Product
Socket MCP Adds Org Alerts, Threat Feed Review, and Package Inspection
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.
Lightweight JavaScript library for simplified HTTP requests with built-in caching and async support.
fetchQuery is a lightweight JavaScript library designed to simplify and optimize HTTP requests. It is ideal for web applications and API integrations, offering asynchronous operations and built-in caching for enhanced performance.
async/await syntax for non-blocking HTTP requests.Install fetchQuery using your preferred package manager:
npm install fetchquery
import fetchQuery from 'fetchquery'
async function fetchData() {
try {
const data = await fetchQuery.get(
'https://jsonplaceholder.typicode.com/todos/1',
)
console.log(data)
} catch (error) {
console.error('Error fetching data:', error)
}
}
fetchData()
const headers = {
Authorization: 'Bearer your-token',
'Custom-Header': 'value',
}
async function fetchDataWithHeaders() {
try {
const data = await fetchQuery.get(
'https://jsonplaceholder.typicode.com/todos/1',
headers,
)
console.log(data)
} catch (error) {
console.error('Error:', error)
}
}
fetchDataWithHeaders()
const postData = {
title: 'New Todo',
completed: false,
}
const headers = {
Authorization: 'Bearer your-token',
'Content-Type': 'application/json',
}
async function createTodo() {
try {
const data = await fetchQuery.post(
'https://jsonplaceholder.typicode.com/todos',
postData,
headers,
)
console.log(data)
} catch (error) {
console.error('Error:', error)
}
}
createTodo()
fetchQuery automatically caches GET responses to avoid redundant network calls:
async function fetchDataWithCache() {
try {
const data1 = await fetchQuery.get(
'https://jsonplaceholder.typicode.com/todos/1',
)
console.log('First Fetch:', data1)
// This will use the cached data
const data2 = await fetchQuery.get(
'https://jsonplaceholder.typicode.com/todos/1',
)
console.log('From Cache:', data2)
} catch (error) {
console.error('Error:', error)
}
}
fetchDataWithCache()
Modify the default cache expiration time (default is 1 hour):
// Set cache expiration time in milliseconds
fetchQuery.setCacheExpirationTime(30 * 60 * 1000) // 30 minutes
get(url, headers) - Sends a GET request.
url: The request URL.headers: Optional custom headers.post(url, data, headers) - Sends a POST request.
url: The request URL.data: Request body.headers: Optional custom headers.put(url, data, headers) - Sends a PUT request.
patch(url, data, headers) - Sends a PATCH request.
delete(url, data, headers) - Sends a DELETE request.
setCacheExpirationTime().{ skipCache: true } to force a new request.We welcome contributions! To contribute:
git checkout -b feature/AmazingFeature).git commit -m 'Add some AmazingFeature').git push origin feature/AmazingFeature).Please follow our contributing guidelines and coding standards.
fetchQuery is licensed under the MIT License.
Inspired by the Fetch API and libraries like Axios to deliver a seamless HTTP request experience.
FAQs
Lightweight JavaScript library for simplified HTTP requests with built-in caching and async support.
The npm package fetchquery receives a total of 0 weekly downloads. As such, fetchquery popularity was classified as not popular.
We found that fetchquery demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.

Research
More than 140 Mastra npm packages were compromised in a supply chain attack that used a typosquatted dependency to deliver a cross-platform infostealer during installation.