2
votes

I'm working with node and a specific library called google-play-scraper. I always get this error whenever I put a variable inside the 'appId', what do I have to do so it does not happen anymore?

Works:

var gplay = require('google-play-scraper');
gplay.app(
{
     appId: 'pink.tap.butterfly.piano.tiles'
}).then(console.log);

Does not work:

var gplay = require('google-play-scraper');
var app = "'pink.tap.butterfly.piano.tiles'";
gplay.app(
{
     appId: app
}).then(console.log);

Error Log:

(node:10716) UnhandledPromiseRejectionWarning: Error: App not found (404) at C:\Users\Daniel Zitei\Pictures\node_modules\google-play-scraper\lib\utils\request.js:42:19 at at process._tickCallback (internal/process/next_tick.js:118:7) (node:10716) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:10716) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

1

1 Answers

1
votes

Cause youve got an extra ' in your string:

  "'pink...'"

just remove that and your id is valid. And you should also do proper error handling:

  var gplay = require('google-play-scraper');
  var app = "pink.tap.butterfly.piano.tiles";

  gplay.app({
     appId: app
  }).then(console.log).catch(console.error);