@hckrnews/auto-fetch

1.1.4 • Public • Published

Auto Fetch local/http

NPM version Coverage Scrutinizer Code Quality Quality Gate Status Bugs Code Smells Technical Debt Vulnerabilities Maintainability Rating Reliability Rating Security Rating

With this package you can get local or remote file data like the fetch method.

Example usage

import fetch '@hckrnews/auto-fetch'

const responseLocal = await fetch('./src/__fixtures__/example.json')
const responseRemote = await fetch('https://example.com')

Returns the body as string.

await response.text()

Returns the body parsed as JSON.

await response.json()

Returns the body as ReadableStream.

let result = ''
response.body.on('data', (chunk) => {
    result += chunk
})

response.body.on('end', () => {
    const data = JSON.parse(result)
})

Package Sidebar

Install

npm i @hckrnews/auto-fetch

Weekly Downloads

0

Version

1.1.4

License

MIT

Unpacked Size

6.75 kB

Total Files

5

Last publish

Collaborators

  • epeus
  • w3news