-
Notifications
You must be signed in to change notification settings - Fork 15
/
listservices.js
31 lines (27 loc) · 890 Bytes
/
listservices.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
* Gets a list of all service request types.
*/
var util = require('util');
var Open311 = require('./lib/open311').Open311;
//Options for the City of Baltimore (see http://311test.baltimorecity.gov/open311).
var options = {
'endpoint': '311test.baltimorecity.gov',
'service_path': '/open311/v2/',
'jurisdiction_id': 'baltimorecity.gov'
};
// Create a new Open311 object.
var report = new Open311(options);
// Call getServiceList method and pass it return format and callback method.
report.getServiceList('json', function(error, data) {
if(error) {
util.puts('WARNING: ' + data);
}
else {
var services = JSON.parse(data);
for(var i = 0; i < services.length; i++) {
util.puts('Service Name: ' + services[i].service_name);
util.puts('Service Code: ' + services[i].service_code);
util.puts('------');
}
}
});