
Security News
Deno 2.6 + Socket: Supply Chain Defense In Your CLI
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.
nanoweb-http
Advanced tools
Nanoweb HTTP is a powerful Node.js package that provides a modern, browser-like fetch API for making HTTP requests in Node.js environments.
Nanoweb HTTP is a powerful Node.js package that provides a modern, browser-like fetch API for making HTTP requests in Node.js environments.
.text(), .json(), .arrayBuffer(), and .stream()Ensure you have Node.js installed, then install the package using npm:
npm install nanoweb-http
The core fetch function allows you to make HTTP requests similar to the browser Fetch API:
// Make a GET request
import fetch from 'nanoweb-http'
const baseUrl = 'http://localhost:3000'
const response = await fetch(`${baseUrl}/data`)
const data = await response.json()
console.log(data)
Convenience methods for common HTTP operations:
// Make a POST request with JSON body
import { post } from 'nanoweb-http'
const baseUrl = 'http://localhost:3000'
const response = await post(`${baseUrl}/api/data`, { name: 'John' })
console.log(response)
The package provides convenient GET method:
// GET request
import { get } from 'nanoweb-http'
const baseUrl = 'http://localhost:3000'
const response = await get(`${baseUrl}/data`)
console.log(response)
The package provides convenient POST method:
// POST request with JSON body
import { post } from 'nanoweb-http'
const baseUrl = 'http://localhost:3000'
const response = await post(`${baseUrl}/api/data`, { message: 'Hello' })
console.log(response)
The package provides convenient PUT method:
// PUT request
import { put } from 'nanoweb-http'
const baseUrl = 'http://localhost:3000'
const response = await put(`${baseUrl}/api/data/1`, { status: 'active' })
console.log(response)
The package provides convenient PATCH method:
// PATCH request
import { patch } from 'nanoweb-http'
const baseUrl = 'http://localhost:3000'
const response = await patch(`${baseUrl}/api/data/1`, { partial: true })
console.log(response)
The package provides convenient DELETE method:
// DELETE request
import { del } from 'nanoweb-http'
const baseUrl = 'http://localhost:3000'
const response = await del(`${baseUrl}/api/data/1`)
console.log(response)
The package provides convenient HEAD method:
// HEAD request
import { head } from 'nanoweb-http'
const baseUrl = 'http://localhost:3000'
const response = await head(`${baseUrl}/data`)
console.log(response)
The package provides convenient OPTIONS method:
// OPTIONS request
import { options } from 'nanoweb-http'
const response = await options(`${baseUrl}/data`)
console.log(response)
Create an API client with base URL and default headers:
// Create API instance with base URL and default headers
import { APIRequest } from 'nanoweb-http'
const baseUrl = 'http://localhost:3000'
const api = new APIRequest(`${baseUrl}/api/`, {
token: '123',
xCustomHeader: 'value'
})
// Make requests using the API instance
const dataResponse = await api.get('data')
const createResponse = await api.post('data', { name: 'John' })
const updateResponse = await api.put('data/1', { status: 'active' })
const deleteResponse = await api.delete('data/1')
console.log(dataResponse, createResponse, updateResponse, deleteResponse)
Handle responses in various formats:
import fetch from 'nanoweb-http'
const baseUrl = 'http://localhost:3000'
const response = await fetch(`${baseUrl}/data`)
console.log(response.ok, response.status)
// Get response as text
const text = await response.text()
console.log(text)
// Get response as JSON
const json = await response.json()
console.log(json)
// Get response as Buffer (binary)
const buffer = await response.arrayBuffer()
console.log(buffer)
// Get raw stream for streaming responses
const stream = response.stream()
console.log(stream)
Handle network and HTTP errors gracefully:
// Request to invalid endpoint
import fetch from 'nanoweb-http'
const baseUrl = 'http://localhost:3000'
try {
const response = await fetch(`${baseUrl}/invalid`)
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`)
}
expect.fail('Request should have failed')
} catch (error) {
console.log(error)
}
Make requests using HTTP/2 protocol:
Handle self-signed certificates with APIRequest:
import { APIRequest } from 'nanoweb-http'
const baseUrl = 'http://localhost:3000'
const api = new APIRequest(`${baseUrl}/api/`, {}, {
allowSelfSignedCertificates: true
})
const response = await api.get('data')
console.log(response)
Add custom headers to requests:
import fetch from 'nanoweb-http'
const baseUrl = 'http://localhost:3000'
const response = await fetch(`${baseUrl}/data`, {
headers: {
'X-Custom-Header': 'value',
'Content-Type': 'application/json'
}
})
console.log(response)
FAQs
Nanoweb HTTP is a powerful Node.js package that provides a modern, browser-like fetch API for making HTTP requests in Node.js environments.
The npm package nanoweb-http receives a total of 0 weekly downloads. As such, nanoweb-http popularity was classified as not popular.
We found that nanoweb-http demonstrated a healthy version release cadence and project activity because the last version was released less than 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.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.