0.1.5 • Published 2 years ago

unstorage-driver-http-headers v0.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago