unstorage-driver-http-headers
TypeScript icon, indicating that this package has built-in type declarations

0.1.5 • Public • Published

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()

Readme

Keywords

none

Package Sidebar

Install

npm i unstorage-driver-http-headers

Weekly Downloads

1

Version

0.1.5

License

MIT

Unpacked Size

12.5 kB

Total Files

14

Last publish

Collaborators

  • tamasmajer