Skip to content

when running a mutation unable to get the response in JSON #112

@ghost

Description

I have added comments:

const dgraph = require('dgraph-js');
const dgraphClient = require('../../config/config').dgraph.client;

module.exports = {
  adduser: async (tnxData) => {
    let res;
    const tnx = dgraphClient.newTxn();

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

      // trying to get response in JSON for checking if it is success or failure
      res = await (await tnx.mutate(mu)).getJson();
      
      await tnx.commit();
    } catch (e) {
      throw new Error(e);
    } finally {
      await tnx.discard();
    }

    console.log(res);
    return res;
  },
};

Following is the error I am getting:

Error: SyntaxError: Unexpected end of JSON input
  

Metadata

Metadata

Labels

status/acceptedWe were able to reproduce the issue and accept to work on it.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions