@hckrnews/local-fetch
v1.2.8
Published
Local Fetch
Downloads
124
Readme
Local Fetch
With this package you can get local file data like the fetch method.
Example usage
import localFetchfrom '@hckrnews/local-fetch'
const fetch = await localFetcher('file:///Users/pieter.wigboldus/projects/local-fetch/src/__fixtures__/example.json')
Returns the body as string.
fetch.text()
Returns the body parsed as JSON.
fetch.json()
Returns the body as ReadableStream.
let result = ''
fetch.body.on('data', (chunk) => {
result += chunk
})
fetch.body.on('end', () => {
const data = JSON.parse(result)
})