ClientToken getting UNDEFINED?

I want to generate clientToken by braintree but I’m getting UNDEFINED…..

var braintree = require("braintree");

// generate client token code

export const braintreeToken = (req, res) => {
  gateway.clientToken.generate({}, function (err, response) {
    if (err) {
      res.status(501).send(err);

      console.log("hello");
    } else {
      res.send(response.clinetToken);
    }
  });
};

Braintree API KEY

var gateway = new braintree.BraintreeGateway({
  environment: braintree.Environment.Sandbox,
  merchantId: "64kmt6hch5g32nrj",
  publicKey: "48k2jnnsbfkjw37g",
  privateKey: "5556a7a162f3046de1166054acd3a562",
});

  • There is a typo. It should be response.clientToken, but you wrote response.clinetToken.

    – 

  • yes but I have changed the type mistake ….I am not getting response….and thus not clientToken

    – 

Leave a Comment