vinbudin
An NPM package to fetch product data from Vínbúðin.
vinbudin
Features
Setup
pnpm add -D vinbudin
npm i -D vinbudin
yarn add -D vinbudin
Why?
Vínbúðin does not provide an open API. This package can be used to analyse their product data or create something else from it.
Basic Usage
import { getProducts } from 'vinbudin'
getProducts().then((products) => {
console.log(products)
})
getProducts({
beer: true,
bubbly: true,
}).then((products) => {
console.log(products)
})
[!NOTE]
This package is designed to be used in a server-side environment. Due to restrictions imposed by browsers regarding cross-origin requests (CORS), attempting to use this package in a client-side (browser) environment may result in errors related to CORS policies.
Methods
getProducts(products) -> promise
Gets products from www.vinbudin.is
- products (Object) is an options object that you can optionally pass in if you want some subset of the data.
It looks like this:
{
beer: true,
red: true,
white: true,
rose: true,
bubbly: true,
fortified: true,
ciderfruitandblends: true,
sakeandmead: true,
strong: true,
aromatised: true,
}
Working with Client-Side Environments
While this package is primarily intended for use in server-side environments, such as Node.js applications, there are workarounds available for integrating it into client-side environments.
Both Nuxt and Next.js support API routes as an example:
Example using Nuxt API routes
import { getProducts } from 'vinbudin'
export default defineEventHandler(async () => {
return await getProducts({ beer: true })
)
<script setup lang="ts">
const { data } = await useFetch('/api/vinbudin')
</script>