0

I'm getting a really weird error called "'scrapeSubreddit' is not defined no-undef" for this function I've created. I'm trying to use the Snoowrap API for Reddit results.

import Snoowrap from 'snoowrap';

function scrapeSubreddit(){
  const r = new Snoowrap({ 
    userAgent: 'myName',
    clientId: 'myID',
    clientSecret: 'mySecret',
  });

  const inspQuote = r.getSubreddit("quotes").getTop({time: 'week',limit:1});
  console.lop(inspQuote);
};


export default scrapeSubreddit;

Edit: I'm also additionally getting several Module not found errors, when I import this .js file into my main .js file for use. I get:

Module not found: Error: Can't resolve 'stream'

Module not found: Error: Can't resolve 'url'

Module not found: Error: Can't resolve 'querystring'

How do I solve this as well?

1 Answers1

0

I think that the problem is in import statement. You should import it like this :

const snoowrap = require('snoowrap');
Nemanja
  • 3,295
  • 11
  • 15
  • Thanks @Nemanja that worked. Now when I'm importing this function into my main.js file, I'm getting a lot of module not found errors. Any tips on how to resolve this? –  Jun 11 '22 at 20:06
  • Checkout this posts: https://stackoverflow.com/questions/55601669/module-not-found-error-cant-resolve-stream-in-c-dev-jszip-test-node-modul , https://stackoverflow.com/questions/70640271/module-not-found-error-cant-resolve-querystring-in-users-apple-documents , https://stackoverflow.com/questions/42855473/webpack-2-module-not-found-when-using-url – Nemanja Jun 11 '22 at 20:10