Skip to content

Commit

Permalink
Fix return value (#885)
Browse files Browse the repository at this point in the history
* Add score api endpoint as pathname

* fix

* Fix return value

* Update package.json

* fix
  • Loading branch information
ChaituVR authored Aug 10, 2023
1 parent 0a21868 commit 4b15337
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@snapshot-labs/snapshot.js",
"version": "0.5.2",
"version": "0.5.3",
"repository": "snapshot-labs/snapshot.js",
"license": "MIT",
"main": "dist/snapshot.cjs.js",
Expand Down
5 changes: 3 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ export async function getScores(
scoreApiUrl = 'https://score.snapshot.org',
options: any = {}
) {
if (!options.returnValue) options.returnValue = 'scores';
const url = new URL(scoreApiUrl);
url.pathname = '/api/scores';
scoreApiUrl = url.toString();
Expand All @@ -241,7 +240,9 @@ export async function getScores(
body: JSON.stringify({ params })
});
const obj = await res.json();
return options.returnValue ? obj.result[options.returnValue] : obj.result;
return options.returnValue === 'all'
? obj.result
: obj.result[options.returnValue || 'scores'];
} catch (e) {
return Promise.reject(e);
}
Expand Down

0 comments on commit 4b15337

Please sign in to comment.