Skip to content

Commit 4b15337

Browse files
authored
Fix return value (#885)
* Add score api endpoint as pathname * fix * Fix return value * Update package.json * fix
1 parent 0a21868 commit 4b15337

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@snapshot-labs/snapshot.js",
3-
"version": "0.5.2",
3+
"version": "0.5.3",
44
"repository": "snapshot-labs/snapshot.js",
55
"license": "MIT",
66
"main": "dist/snapshot.cjs.js",

src/utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ export async function getScores(
222222
scoreApiUrl = 'https://score.snapshot.org',
223223
options: any = {}
224224
) {
225-
if (!options.returnValue) options.returnValue = 'scores';
226225
const url = new URL(scoreApiUrl);
227226
url.pathname = '/api/scores';
228227
scoreApiUrl = url.toString();
@@ -241,7 +240,9 @@ export async function getScores(
241240
body: JSON.stringify({ params })
242241
});
243242
const obj = await res.json();
244-
return options.returnValue ? obj.result[options.returnValue] : obj.result;
243+
return options.returnValue === 'all'
244+
? obj.result
245+
: obj.result[options.returnValue || 'scores'];
245246
} catch (e) {
246247
return Promise.reject(e);
247248
}

0 commit comments

Comments
 (0)