Created
April 17, 2019 18:39
-
-
Save pmichk/eb516092a503c04ed0b0a465f1a7c603 to your computer and use it in GitHub Desktop.
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
"use strict"; | |
const querystring = require("querystring"); | |
const request = require('request-promise'); | |
module.exports = async (context, callback) => { | |
const article = querystring.escape(context); | |
const uri = `https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&titles=${article}&redirects=true`; | |
let response = await request({ | |
uri, | |
json: true | |
}); | |
callback(undefined, response.query.pages[Object.keys(response.query.pages)[0]].extract); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment