Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is toJSON required for generateKeywordIdeas? #478

Open
amosbastian opened this issue Oct 11, 2023 · 2 comments
Open

Why is toJSON required for generateKeywordIdeas? #478

amosbastian opened this issue Oct 11, 2023 · 2 comments

Comments

@amosbastian
Copy link

I am trying to generate keyword ideas with

const result = await customer.keywordPlanIdeas.generateKeywordIdeas({
  customer_id: Config.GOOGLE_CUSTOMER_ID,
  geo_target_constants: [],
  include_adult_keywords: true,
  keyword_plan_network: "UNSPECIFIED",
  keyword_annotation: [],
  page_size: 10,
  page_token: "",
  ...request,
});

but it's complaining that

Types of property 'toJSON' are incompatible.
    Type '(() => { [k: string]: any; }) | undefined' is not assignable to type '() => { [k: string]: any; }'.

Of course you can just add

toJSON: () => ({}),

but then again, why is it required? And what does it actually do? There isn't any documentation for it as far as I can tell.

@lalawow
Copy link

lalawow commented Nov 19, 2024

The args of customer.keywordPlanIdeas.generateKeywordIdeas is a class.
So we'd better to use these rpcs in this way:

    const request = new services.GenerateKeywordIdeasRequest({
      customer_id: GOOGLE_ADS_CUSTOMER_ID,
      geo_target_constants: [],
      include_adult_keywords: true,
      keyword_plan_network: 'UNSPECIFIED',
      keyword_annotation: [],
      page_size: 10,
      page_token: '',
      ...options,
    });

    const result =
      await customer.keywordPlanIdeas.generateKeywordIdeas(request);

@lalawow
Copy link

lalawow commented Nov 19, 2024

BTW, these classes are defined in google-ads-node.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants