@hckrnews/auto-fetch
v1.1.5
Published
Auto Fetch local/http
Downloads
52
Readme
Auto Fetch local/http
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)
})