JavaScript client for covid-local-api, a REST API to get local information and addresses on COVID-19 (hotlines, websites, test sites, health departments).
This JavaScript package is automatically generated by the OpenAPI Generator project.
You can install directly with npm from github:
npm install cotect/covid-local-js --save
To install the client locally for development, run:
git clone https://github.com/cotect/covid-local-js.git
cd covid-local-js
npm install
Next, link it globally in npm with the following:
npm link
To use the link you just defined in your project, switch to the directory you want to use the client from, and run:
npm link /path/to/covid-local-js
Finally, you need to build the module:
npm run build
The library also works in the browser environment via npm and browserify. After following
the above steps with Node.js and installing browserify with npm install -g browserify
,
perform the following (assuming main.js is your entry file):
browserify main.js > bundle.js
Then include bundle.js in the HTML pages.
Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config:
module: {
rules: [
{
parser: {
amd: false
}
}
]
}
var CovidLocal = require('covid-local-js');
var api = new CovidLocal.DefaultApi()
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
// Get all items (hotlines, websites, test sites, health departments) for Berlin Mitte
api.getAll( {'placeName': "Berlin Mitte"} , callback);
// Get the 3 closest test sites for Berlin Mitte
api.getTestSites( {'placeName': "Berlin Mitte", "limit": 3} , callback);
// Do the same thing, but define the place via its geonames.org ID
api.getTestSites( {'geonamesId': 2950159, "limit": 3} , callback);
// Search for places matching the query "Berlin Mitte"
// (this will also yield the geonames IDs of these places)
api.searchPlaces( {'q': "Berlin Mitte"} , callback);
For further documentation, see below and the readme file of covid-local-api.
Class | Method | HTTP request | Description |
---|---|---|---|
CovidLocal.DefaultApi | getAll | GET /all | Get all items for a place |
CovidLocal.DefaultApi | getHealthDepartments | GET /health_departments | Get responsible health departments for a place |
CovidLocal.DefaultApi | getHotlines | GET /hotlines | Get hotlines for a place |
CovidLocal.DefaultApi | getTestSites | GET /test_sites | Get nearby test sites for a place (sorted by distance to place) |
CovidLocal.DefaultApi | getWebsites | GET /websites | Get websites for a place |
CovidLocal.DefaultApi | searchPlaces | GET /places | Search for places via free-form query |
CovidLocal.DefaultApi | test | GET /test | Shows all entries for Berlin Mitte (redirects to /all endpoint) |