-
-
Save goldcaddy77/df22bb57fd118ff5f046a32c27f4554c to your computer and use it in GitHub Desktop.
Apollo datasource REST
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { | |
RESTDataSource | |
} = require('apollo-datasource-rest'); | |
class TellusAPI extends RESTDataSource { | |
constructor() { | |
super(); | |
this.baseURL = 'https://api.kernel.telluslabs.com/api/v1/'; | |
} | |
// https://api.kernel.telluslabs.com/api/v1/metrics/? | |
async getMetrics() { | |
const res = await this.get('metrics', { | |
api_key: process.env.ENGINE_API_KEY, | |
country_iso: 'USA', | |
geo_level: 'level_1', | |
metric_code: 'TLUSM2SMTH', | |
geo_id: '00', | |
time_format: 'timestamp', | |
include_metadata: 'true', | |
start_date: '2018-04-01', | |
end_date: '2018-11-14', | |
crop: 'corn' | |
}); | |
return res && res.length ? res : []; | |
} | |
} | |
module.exports = TellusAPI; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment