1.0.0 • Published 2 years ago

aldi-wrapper v1.0.0

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

Unofficial Node.js API wrapper for the Dutch Aldi.

Installation

npm install aldi-wrapper

or

yarn add aldi-wrapper

then

import { Aldi } from 'aldi-wrapper';

Basic usage

// Creates Aldi object, set verbose to true to see all requests
const aldi = new Aldi({ verbose: true });
// Gets products by name
const products = await aldi.product().getProductsFromName('melk');

More information about the functions and parameters can be found on the wiki

Example usage

For all of these examples, please keep in mind that your function in which you request something should be async since the requests return a Promise.

Product

If I want to find all product names that match a given query:

import { Aldi } from 'aldi-wrapper';

async function findProducts(productName: string) {
    const aldi = new Aldi();
    const products = await aldi.product().getProductsFromName(productName);
    console.log(
        products.articles.map((article) => {
            return article.title;
        })
    );
}

findProducts('karnemelk');
[ 'Karnemelk ', 'Biologische karnemelk', 'Karnemelkdessert' ]

Recipe

If I want to find all recipe names that match a given query:

import { Aldi } from 'aldi-wrapper';

async function findRecipes(recipeName: string) {
    const aldi = new Aldi();
    const recipes = await aldi.recipe().getRecipesFromName(recipeName);
    console.log(
        recipes.recipes.map((recipe) => {
            return recipe.title;
        })
    );
}

findRecipes('pizza');
[
  'Pizza rolls gevuld met kip',
  'Pizza met gehakt',
  'Homemade pizza',
  'Pizza met ansjovis',
  'Gezonde Sinterklaas-snack: pizza toast met verstopte groenten',
  'Pizza van Turks brood met hummus en gefrituurde aubergine',
  'Vegetarische pizza',
  'Mini bladerdeegpizza’s met tomatensaus, kaas en basilicum',
  'Vier soorten zelfgemaakte bladerdeeghapjes '
]
1.0.0

2 years ago