Created
June 14, 2017 04:28
-
-
Save PreSoichiSumi/22edef6106b4cfa9bdd35b56669c9433 to your computer and use it in GitHub Desktop.
request-promiseを使ってgetできるかのテスト
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
//https://github.com/request/request-promise | |
var rp= require('request-promise'); | |
var options = { | |
uri: 'https://gist.githubusercontent.com/SoichiSumi/5bed3eb79ae8ec97b193f3ca35841990/raw/6d4beeb68822cd9d6af4a164bbfaeab3a9c050a9/test.json', | |
/*qs: { | |
access_token: 'xxxxx xxxxx' // -> uri + '?access_token=xxxxx%20xxxxx' | |
},*/ | |
headers: { | |
'Origin':'https://github.com/', | |
'Referer':'https://github.com/SoichiSumi/SoichiSumi.github.io' | |
}, | |
json: true // Automatically parses the JSON string in the response | |
}; | |
exports.handler = (event, context, callback) => { | |
console.log("one"); | |
rp(options) | |
.then(function (repos) { | |
console.log('User has %s repos', JSON.stringify(repos)); | |
callback(null,repos); | |
}) | |
.catch(function (err) { | |
callback(err); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment