[英]'require' is not defined VS Code
我是 VS Code 的新手。 正如標題所示,我試圖要求各種 SDK 讓我的 JEE 正常運行。 當我嘗試 go 直播時,控制台會吐出這個錯誤:
Uncaught ReferenceError: require is not defined
at fbaccess.js:10
我記得在 Android 的開發日中,我們總是有一個清單文件來要求東西,但我不確定如何在 VS Code 中全局導入/正確調用東西。
這是應該調用一些示例數據的 fbaccess.js 代碼(在 node.js 中輸出:
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
* @flow
*/
const bizSdk = require('facebook-nodejs-business-sdk');
const AdAccount = bizSdk.AdAccount;
const AdsInsights = bizSdk.AdsInsights;
let access_token = '****';
let ad_account_id = '****';
let app_secret = '****';
let app_id = '****';
const api = bizSdk.FacebookAdsApi.init(access_token);
const account = new AdAccount(ad_account_id);
const showDebugingInfo = true; // Setting this to true shows more debugging info.
if (showDebugingInfo) {
api.setDebug(true);
}
let ads_insights;
let ads_insights_id;
const logApiCallResult = (apiCallName, data) => {
console.log(apiCallName);
if (showDebugingInfo) {
console.log('Data:' + JSON.stringify(data));
}
};
const fields = [
'results',
'impressions',
'spend',
'quality_score_organic',
];
const params = {
'level' : 'campaign',
'filtering' : [],
'breakdowns' : [],
'time_range' : {'since':'2019-10-09','until':'2019-10-09'},
};
(new AdAccount(ad_account_id)).getInsights(
fields,
params
).then((result) => {
logApiCallResult('ads_insights api call complete.', result);
ads_insights_id = result[0].id;
})
.catch((error) => {
console.log(error);
});
任何幫助,將不勝感激!
將此添加到頭部的 html 中。
<script type="text/javascript" src="https://unpkg.com/jquery@3.3.1/dist/jquery.js"></script>
<script type="text/javascript" src="https://unpkg.com/web3@0.20.5/dist/web3.min.js"></script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.