mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-22 09:35:10 +00:00
Merge "[FAB-15717] fix Error Unexpected end of JSON input"
This commit is contained in:
commit
7a5f3398a9
2 changed files with 12 additions and 4 deletions
|
|
@ -42,8 +42,12 @@ class StateList {
|
||||||
async getState(key) {
|
async getState(key) {
|
||||||
let ledgerKey = this.ctx.stub.createCompositeKey(this.name, State.splitKey(key));
|
let ledgerKey = this.ctx.stub.createCompositeKey(this.name, State.splitKey(key));
|
||||||
let data = await this.ctx.stub.getState(ledgerKey);
|
let data = await this.ctx.stub.getState(ledgerKey);
|
||||||
let state = State.deserialize(data, this.supportedClasses);
|
if (data && data.toString('utf8')) {
|
||||||
return state;
|
let state = State.deserialize(data, this.supportedClasses);
|
||||||
|
return state;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,12 @@ class StateList {
|
||||||
async getState(key) {
|
async getState(key) {
|
||||||
let ledgerKey = this.ctx.stub.createCompositeKey(this.name, State.splitKey(key));
|
let ledgerKey = this.ctx.stub.createCompositeKey(this.name, State.splitKey(key));
|
||||||
let data = await this.ctx.stub.getState(ledgerKey);
|
let data = await this.ctx.stub.getState(ledgerKey);
|
||||||
let state = State.deserialize(data, this.supportedClasses);
|
if (data && data.toString('utf8')) {
|
||||||
return state;
|
let state = State.deserialize(data, this.supportedClasses);
|
||||||
|
return state;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue