GeoWrapper is a wrapper that allows easy access to the Rest-Countries API
- Open the terminal in your project directory.
- then run -->
npm install @lufthor/geowrapper
in the terminal
- This package uses the
https
module found inNode.JS
and uses modules - Here is sample code of one of the functions
async function returnRegionInfo(region) {
let url = `https://restcountries.com/v3.1/region/${region}`
return new Promise((resolve, reject) => {
https.get(url, (res) => {
let data = ''
res.on('data', (chunk) => {
data += chunk;
})
res.on('end', () => {
try {
const jsonData = JSON.parse(data)
resolve(expandArraysAndObjects(jsonData))
} catch (error) {
throw new Error(error)
}
})
})
})
}
I'm open to contributions so go ahead, I don't mind as long as the code is clean and is tested before-hand.
- Once you've ran the command from here
- Create a new JS file.
- at the top write
const gw = require('@lufthor/geowrapper')
ORconst gw = require('geowrapper')
The documentation can be found HERE