unstorage-driver-http-headers
v0.1.5
Published
A generalization of the default unstorage http driver, to allow sending headers (for authentication).
Downloads
6
Readme
unstorage-driver-http-headers
This is a simple extension of the default http driver for Unstorage. Here are the docs.
It allows to add extra headers to the http requests, like an access token or a session ID.
Install
npm install unstorage
npm install unstorage-driver-http-headers
Example
import { createStorage } from 'unstorage'
import createDriver from 'unstorage-driver-http-headers'
const SAMPLE_URL = 'https://my-unstorage-server-needs-credentials.com/api'
const SAMPLE_HEADERS = { 'credentials': 'my-credentials' }
const driver = createDriver({ base: SAMPLE_URL, headers: SAMPLE_HEADERS })
const storage = createStorage({ driver })
const testing = async () => {
await storage.setItem("key","value")
const value = await storage.getItem("key")
const exists = await storage.hasItem("key")
const keys = await storage.getKeys()
await storage.removeItem("key")
console.log({value, exists, keys})
}
testing()