mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-19 00:15:08 +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) {
|
||||
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