Tnx not defined while doing `tnx.commit()` using dgraphjs

Added comments inside the following code

const dgraph = require('dgraph-js');
const dgraphClient = require('../../config/config').dgraph.client;
const registerSchema = require('../../schema/auth/register.schema');

module.exports = async (data) => {
  let res;
  let tnx = dgraphClient.newTxn();

  const {error, value: tnxData} = registerSchema.validate(data);
  if (error) {
    throw new Error(`Schema validation error: ${error.message}`);

  try {
    const mu = new dgraph.Mutation();

    res = await tnx.mutate(mu); // no error working super fine

    await txn.commit(); // throwing error (tnx is not defined)

    console.log('All created nodes (map from blank node names to uids):');
  } catch (e) {
    throw new Error(e);
  } finally {
    await tnx.discard();

  return res;

Also, I am not setting any Schema beforehand…directly trying to mutate.

Never mind I was writing txn instead of tnx.