Google-api-nodejs-client: adsense & adsensehost fail with "Unable to load endpoint adsensehost("v2"): ctr is not a constructor"

Created on 28 Aug 2019  路  3Comments  路  Source: googleapis/google-api-nodejs-client

Looking everywhere for some docs on how to use googleapis with adsense and/or adsensehost (not sure what the difference is... where is this explained?)

Doing this:

const { google } = require('googleapis');


const adsense = google.adsensehost({
    version: 'v2',  // tried v3, v1... same effect
    auth: 'api key here'
});

results in:

 ERROR  Unable to load endpoint adsensehost("v1"): ctr is not a constructor                                   16:14:54

  Error: Unable to load endpoint adsensehost("v1"): ctr is not a constructor
  at Object.getAPI (node_modules\googleapis-common\build\src\apiIndex.js:36:15)
  at GoogleApis.adsensehost (node_modules\googleapis\build\src\apis\adsensehost\index.js:22:32)
  at Object.<anonymous> (api\server.js:16:24)
  at Generator.next (<anonymous>)

Unsure where to go from here.

question

Most helpful comment

馃憢 I know it's clear as mud, but you can find the version for each API in the corresponding src/apis directory:

https://github.com/googleapis/google-api-nodejs-client/tree/master/src/apis/adsense

Adsense in this case is v1.4, I hope this gets you on your feet 馃憤

All 3 comments

@madc0w try version 4.1, this appears to be the version of this API that we're shipping.

Oh! You meant the version of adsensehost, not the googleapis version. Great, so now this works fine:

const adsense = google.adsensehost({
    version: 'v4.1',
    auth: 'api key'
});

but... this still crashes in the same manner as before:

const adsense = google.adsense({
    version: 'v4.1',
    auth: 'api key'
});

Can you please tell me what is the proper version of adsense I should be using?

馃憢 I know it's clear as mud, but you can find the version for each API in the corresponding src/apis directory:

https://github.com/googleapis/google-api-nodejs-client/tree/master/src/apis/adsense

Adsense in this case is v1.4, I hope this gets you on your feet 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hainguyents13 picture hainguyents13  路  3Comments

ashishbajaj99 picture ashishbajaj99  路  3Comments

lowagner picture lowagner  路  3Comments

ovaris picture ovaris  路  3Comments

JustinBeckwith picture JustinBeckwith  路  3Comments