facebook / facebook-nodejs-business-sdk

Node.js SDK for Meta Marketing APIs
https://developers.facebook.com/docs/business-sdk
Other
497 stars 227 forks source link

Trying to run one of the basic SDK examples results in SDK crash #271

Closed jobiewong closed 8 months ago

jobiewong commented 8 months ago

Which SDK version are you using?

v19.0.0

What's the issue?

Running the minimum example setup as provided in the /examples/ad_account_node.js results in the error message: CrashReporter: SDK crash detected! Not be able to find appID, fail to send report to server.

Steps/Sample code to reproduce the issue

Run a .js file with the code given in the example

const bizSdk = require('facebook-nodejs-business-sdk');
const AdAccount = bizSdk.AdAccount

const access_token = {META_ACCESS_TOKEN};
const app_secret ={META_APP_SECRET};
const app_id = {META_APP_ID};
const id = "act_" + {META_ACCOUNT_ID};
const api = bizSdk.FacebookAdsApi.init(access_token);
const showDebugingInfo = true; // Setting this to true shows more debugging info.
if (showDebugingInfo) {
  api.setDebug(true);
}

const logApiCallResult = (apiCallName, data) => {
  console.log(apiCallName);
  if (showDebugingInfo) {
    console.log("Data:" + JSON.stringify(data));
  }
};

const fields = ["name"];
const params = {};
const sample_code = new AdAccount(id).get(fields, params);
logApiCallResult("sample_code api call complete.", sample_code);

Observed Results:

The console repeatedly prints the following error:

CrashReporter: SDK crash detected!
Not be able to find appID, fail to send report to server.

Expected Results:

The name of the account linked with the provided account_id should be printed.

jobiewong commented 8 months ago

Unless I am missing something very obvious, there appears to be no actual reference to the app_id after it is defined in any of the code examples. In the Javascript SDK the api is initialised with the app_id and app_secret but this doesn't appear to be the case in the NodeJs SDK.