Lod-opendata - npm package
Publié le 22 décembre 2020
Roberto Entringer
Focusing primarily on simplicity, I develop powerful, clean, smart, efficient, web apps, responsive websites, WordPress themes and plugins. I am practiced in the areas of hosting, SEO, progressive web apps, back-end and front-end development. ROBERTO ENTRINGER - Full-stack Web Developer @ Luxembourg
1 jeux de données
4 réutilisations
Informations
- Type
- Application
- Thématique
- Autres
- ID
- 5fe21ed547d5a5f0f1bf92e2
Publication
Intégrer sur votre site
URL stable
Description
Lod-opendata
A NPM package for get data of Lëtzebuerger Online Dictionnaire (LOD) from data.public.lu.
Repo on Github : https://github.com/robertoentringer/lod-opendata
Npm package : https://www.npmjs.com/package/lod-opendata
Installation
$ npm install lod-opendata
Usage
const opendata = require('lod-opendata')
// Example with async / Await
const asyncAwait = async () => {
//Get all fields. Use defaults
try {
const result = await opendata()
console.log(result)
} catch (error) {
console.log(error.message)
}
}
asyncAwait()
// Example with then / catch
const thenCatch = () => {
//Get all fields. Use defaults
opendata()
.then((obj) => console.log(obj))
.catch((err) => console.log(err.message))
//Get all fields from the main `resources` field'
opendata('resources')
.then((obj) => console.log(obj))
.catch((err) => console.log(err.message))
//Get the `url` field from `resources` field'
opendata('resources/{url}')
.then(({ resources: [{ url }] }) => console.log(url))
.catch((err) => console.log(err.message))
//Get multiple main fields: `page`, `title`, `slug`
opendata('page,title,slug')
.then(({ page, title, slug }) => console.log(page, title, slug))
.catch((err) => console.log(err.message))
//Get multiple subfields: `id`, `published`, `latest` from main field `resources`
opendata('resources/{id,published,latest}')
.then(({ resources: [{ id, published, latest }] }) => console.log(id, published, latest))
.catch((err) => console.log(err.message))
//Get all fields pass a custom api `url`. Useful if the API URL changes.
const url = 'http://data.public.lu/api/1/datasets/letzebuerger-online-dictionnaire-raw-data'
opendata('', url)
.then((obj) => console.log(obj))
.catch((err) => console.log(err.message))
}
thenCatch()
Jeux de données utilisés 0
Discussion entre le producteur et la communauté à propos de cette réutilisation.
Plus de réutilisations
Découvrez davantage de réutilisations.