javascriptreactjsreddit

Reddit API not returning NSFW posts


When i put the link into the browser i am getting results, just not when im making a call from my app. I first assumed this was something by reddit but if so then why would i be able to see the data from the browser. Below are two example links, One works and one doesnt - the only difference is one is from a NSFW sub.

axios.get('https://www.reddit.com/r/nsfw/search.json?q=example&restrict_sr=true')


axios.get('https://www.reddit.com/r/aww/search.json?q=cat&limit=1&sort=top&restrict_sr=true&after=null')

Solution

  • You would need to include the include_over_18 parameter.

    Try axios.get('https://www.reddit.com/r/nsfw/search.json?q=example&restrict_sr=true&include_over_18=on')