Required parameter currencyId was null or undefined when calling incrementPlayerCurrencyBalance.

Hi I'm having a problem with using the economyAPI through cloud code. I can get the currency balances to increment and decrement when using the cloudcode parameters to set the currencyID as per the examples, but when I try and hardcode the currencyID I get the error:
Required parameter currencyId was null or undefined when calling incrementPlayerCurrencyBalance.
Here's my code:

    const lunchBoxCurrencyId = 'LUNCHBOX';
    const currencyId  = params.currencyId;

    // log typeof and value
    logger.info(typeof currencyId);
    logger.info(typeof lunchBoxCurrencyId);
    logger.info( currencyId + " == " + lunchBoxCurrencyId);

    // works:
    const increment = await currencies.incrementPlayerCurrencyBalance({ projectId, playerId, currencyId, currencyModifyBalanceRequest: { amount: 10 } });

    // doesnt work:
    const increment2 = await currencies.incrementPlayerCurrencyBalance({ projectId, playerId, lunchBoxCurrencyId, currencyModifyBalanceRequest: { amount: 10 } });

And this is what is output in the console:
info string
info string
info LUNCHBOX == LUNCHBOX

Im sure its just some basic misunderstanding of javascript on my behalf but I dont understand how 2 variables with the same type, scope and value can have different results.

Ah Ive fixed it myself the variable passed into the method has to be named currencyId!
Still getting used to Javascript :)

2 Likes

I met the same issue... By the way, what does this JS Grammar called ?