reddit

The Implementation

As previously mentioned snoowrap is the recommended JavaScript wrapper for the reddit API. This page will walk you through the various components of snoowrap

NOTE: OAuth2 credentials are required a requirement for the Reddit API. See the previous page to create a key and web application

Below is an example of a complete Reddit API request using snoowrap. After the complete view, we will explain each section in more detail. Snoowrap uses Methods to get and return data from Reddit to a url or the console log.

NOTE: you may receive an error message to display blocked content or that the page is trying to load unsafe content. Select the option to load the blocked content. There is a known issue with browsers displaying Jsfiddle using Github Pages.

Let's break down what we see

'use strict' is a javaScript directive that notifies JavaScript that the file should be executed in strict mode. 'const snoowrap = require('snoowrap') is a class required to access the methods of the snoowrap library. This is similar to HttpRequest we've used before.

Either of these two pieces of code create a new snoowrap request with OAuth2 credentials. All of the fields are required using the information you received when creating a new app

These are various requests that can be made using snoowrap methods.

We will look at examples of actual content on the next page.