
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@ejnshtein/smol-request
Advanced tools
Tiny http/https request wrapper for Node.js using ESM (13.5 and newer)
Small async request client for Node.js 13.5 and newer with 0 dependencies.
import request from 'smol-request'
request('https://ghibliapi.herokuapp.com/films', { responseType: 'json' })
.then(({ data }) => {
console.log(`Studio Ghibli has ${response.data.length} movies out there!`)
})
request('https://bbc.com')
.then(({ data }) => {
// bbc page is too big to log it to console, but we can save it to the drive!
fs.promises.writeFile('./bbc.html', data) // we are using only Node 13.5 and newer and promises are stable here
.then(() => {
console.log('bbc page saved!')
})
})
request('https://i.picsum.photos/id/1025/200/300.jpg', { responseType: 'buffer' })
.then(({ data }) => {
fs.promises.writeFile('./picture.jpg', data)
.then(() => {
console.log('picture saved!')
})
})
request('https://i.picsum.photos/id/1025/200/300.jpg', { responseType: 'stream' })
.then(({ data }) => {
const stream = fs.createWriteStream('./picture.jpg')
data.pipe(stream)
data.once('finish', () => {
console.log('picture saved!')
})
})
OR you can get only headers without parsing body from request using responseType: 'headers'
request(url[,
options[,
formData]]): Promise<
Response>
This client uses base http/https Node.js request client, so it inherits all options from it. (Description)
Name | Type | Default | Description |
---|---|---|---|
params | Object | {} | URLSearchParams of request url.(Example: { q: 'my search query' } becomes -> http://myurl?q=my+search+query ) |
responseType | String | text | One of these values: text , buffer , json , stream , headers |
Name | Type | Description |
---|---|---|
data | ReadableStream | Object | String | Buffer | Null | Response data with choosen type from responseType . |
headers | Object | Response headers. |
status | Number | Reponse status. |
statusText | String | Response status text. |
If you are sending form data note that you can send form from FormData using it's method form.submit(path, err => {})
.
This option can be Object(then it will become string) or your custom property that will be written to request body with req.write(). ( ‾ʖ̫‾)
FAQs
Tiny http/https request wrapper for Node.js 10 and newer
The npm package @ejnshtein/smol-request receives a total of 0 weekly downloads. As such, @ejnshtein/smol-request popularity was classified as not popular.
We found that @ejnshtein/smol-request 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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.