AssertionError: Failure: Cannot coerce to b64 string: number


(Najmul Hosain) #1

After executing in js

let userSaveStr = `
            _:tk <token> "${token}" (createdAt=${now}) .
            _:user <user.token> _:tk .
            _:user <sub> "${payload.sub}" .
            _:user <email> "${payload.email}" .
            _:user <name> "${payload.name}" .
            _:user <avatar> "${payload.picture}" .
            _:user <createdAt> "${now}" .
          `;
        const mu = new dgraph.Mutation(new Uint8Array(Buffer.from(userSaveStr)));
        mu.setCommitNow(true);
        mu.setSetNquads(mu);
        await transaction.mutate(mu);

ERROR LOG

AssertionError: Failure: Cannot coerce to b64 string: number
      at new goog.asserts.AssertionError (/home/najmul/WebstormProjects/api.quiz-quiz.shadhin.space/node_modules/google-protobuf/google-protobuf.js:98:603)
      at Object.goog.asserts.fail (/home/najmul/WebstormProjects/api.quiz-quiz.shadhin.space/node_modules/google-protobuf/google-protobuf.js:100:89)
      at Function.jspb.Message.bytesAsB64 (/home/najmul/WebstormProjects/api.quiz-quiz.shadhin.space/node_modules/google-protobuf/google-protobuf.js:199:194)
      at proto.api.Mutation.getSetJson_asB64 (/home/najmul/WebstormProjects/api.quiz-quiz.shadhin.space/node_modules/dgraph-js/generated/api_pb.js:1019:46)
      at Function.proto.api.Mutation.toObject (/home/najmul/WebstormProjects/api.quiz-quiz.shadhin.space/node_modules/dgraph-js/generated/api_pb.js:822:18)
      at proto.api.Mutation.toObject (/home/najmul/WebstormProjects/api.quiz-quiz.shadhin.space/node_modules/dgraph-js/generated/api_pb.js:807:29)
      at Object.stringifyMessage (/home/najmul/WebstormProjects/api.quiz-quiz.shadhin.space/node_modules/dgraph-js/lib/util.js:54:31)
      at Txn.<anonymous> (/home/najmul/WebstormProjects/api.quiz-quiz.shadhin.space/node_modules/dgraph-js/lib/txn.js:106:68)
      at step (/home/najmul/WebstormProjects/api.quiz-quiz.shadhin.space/node_modules/dgraph-js/lib/txn.js:32:23)
      at Object.next (/home/najmul/WebstormProjects/api.quiz-quiz.shadhin.space/node_modules/dgraph-js/lib/txn.js:13:53)

I can’t figure it out :frowning:


(system) #2

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.