Skip to content

Instantly share code, notes, and snippets.

@pmichk
Created April 17, 2019 18:39
Show Gist options
  • Save pmichk/eb516092a503c04ed0b0a465f1a7c603 to your computer and use it in GitHub Desktop.
Save pmichk/eb516092a503c04ed0b0a465f1a7c603 to your computer and use it in GitHub Desktop.
"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