0

Get word meaning from Urban Dictionary

Function JavaScript 1 revisions 97 8 months ago 8 months ago
const axios = require('axios');

function wat(term) {
	return axios.get('https://api.urbandictionary.com/v0/define', {params: {term}})
		.then(response => ({
			definition: response.data.list[0].definition,
			example: response.data.list[0].example,
			votes: response.data.list[0].thumbs_up - response.data.list[0].thumbs_down,
		}));
}

This gets the definition of a thing from Urban Dictionary thing.

wat('brb').then(console.log);

/*
{ definition: 'Acronym for "be right back"',
  example: 'Hey, brb, g2g take a shit',
  votes: 3228 }
*/

You can use something other than axios but Promises ftw.