mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-18 16:05:10 +00:00
[FAB-15717] fix Error Unexpected end of JSON input
Change-Id: If5700abbe8315ece19e488e2d1ee0e0a7f0b8f49 Signed-off-by: Huida Liu <cefold@gmail.com>
This commit is contained in:
parent
779f8f3418
commit
6ae711cf7b
2 changed files with 12 additions and 4 deletions
|
|
@ -42,8 +42,12 @@ class StateList {
|
|||
async getState(key) {
|
||||
let ledgerKey = this.ctx.stub.createCompositeKey(this.name, State.splitKey(key));
|
||||
let data = await this.ctx.stub.getState(ledgerKey);
|
||||
let state = State.deserialize(data, this.supportedClasses);
|
||||
return state;
|
||||
if (data && data.toString('utf8')) {
|
||||
let state = State.deserialize(data, this.supportedClasses);
|
||||
return state;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -42,8 +42,12 @@ class StateList {
|
|||
async getState(key) {
|
||||
let ledgerKey = this.ctx.stub.createCompositeKey(this.name, State.splitKey(key));
|
||||
let data = await this.ctx.stub.getState(ledgerKey);
|
||||
let state = State.deserialize(data, this.supportedClasses);
|
||||
return state;
|
||||
if (data && data.toString('utf8')) {
|
||||
let state = State.deserialize(data, this.supportedClasses);
|
||||
return state;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue