簡體   English   中英

使用 Reddit API 時出現 Helper function is not defined 錯誤?

[英]Helper function is not defined error when using Reddit API?

對於我創建的這個 function,我收到一個非常奇怪的錯誤,稱為“'scrapeSubreddit' 未定義 no-undef”。 我正在嘗試將 Snoowrap API 用於 Reddit 結果。

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;

編輯:當我將 this.js 文件導入到我的 main.js 文件中以供使用時,我還遇到了幾個模塊未找到的錯誤。 我得到:

找不到模塊:錯誤:無法解析“流”

找不到模塊:錯誤:無法解析“url”

找不到模塊:錯誤:無法解析“querystring”

我該如何解決這個問題?

我認為問題出在導入語句中。 你應該像這樣導入它:

const snoowrap = require('snoowrap');

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM