Closed NullP0interEx closed 7 years ago
There're a thousand ways to do this, and it's a bit beyond the scope of this project, here's one with request-promise.
app.intent('ReposIntent', {}, function(req, res) {
var options = {
uri: 'https://api.github.com/user/repos',
qs: {
access_token: 'xxxxx xxxxx'
},
json: true
};
return rp(options)
.then(function (repos) {
res.say('User has ' + repos.length + ' repos.');
});
});
Can you please add an example skill with a http request? I want to query an API but i think my way is not so perfect.
`var alexa = require('alexa-app'); var async = require('async'); var request = require('request');
// Allow this module to be reloaded by hotswap when changed module.change_code = 1;
// Define an alexa-app var app = new alexa.app('hello_world');
async.parallel([ function(callback) { var options = { url: 'https://xxxxxxxxxx.de/ddd', timeout: 3000 } request(options, function(err, response, body) { // JSON body if(err) { console.log(err); callback(true); return; } obj = JSON.parse(body); callback(false, obj); }); }], function(err, results) { app.launch(function(req, res) { sayToday(results[0], req, res); });
);`