Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
"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