forked from osmosis-labs/assetlists
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cache Pools Query to New File (osmosis-labs#1030)
* save pools query to dedicated file * re add queryPool()
- Loading branch information
1 parent
3524e0e
commit cd3f094
Showing
7 changed files
with
50,915 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
//Purpose: | ||
// to query APIs and record ('cache') the results for each result to a file. | ||
|
||
|
||
//-- Imports -- | ||
|
||
import * as fs from 'fs'; | ||
import * as zone from './assetlist_functions.mjs'; | ||
|
||
|
||
|
||
|
||
|
||
//-- Global Variables -- | ||
|
||
const queryResponsesDirectoryName = "query_responses"; | ||
|
||
|
||
|
||
|
||
|
||
|
||
//-- Functions -- | ||
|
||
//--Query URL-- | ||
export async function queryAPI(baseUrl, params, chainName, fileName) { | ||
|
||
console.log(baseUrl); | ||
const options = { | ||
method: 'GET', | ||
accept: 'application/json' | ||
} | ||
let url; | ||
let response; | ||
let result; | ||
let param = null; | ||
let paginationKey = ""; | ||
const paginationLimit = 2000; | ||
|
||
param = `?pagination.limit=${paginationLimit}` | ||
if(param) { | ||
url = baseUrl + param; | ||
} | ||
response = await fetch(url,options); | ||
result = await response.json(); | ||
if (!result) { | ||
console.log("No result to: ${url}"); | ||
return; | ||
} | ||
//console.log(result); | ||
|
||
await zone.writeToFile(chainName, queryResponsesDirectoryName, fileName, result); | ||
console.log("Saved API Query Response!"); | ||
|
||
} | ||
|
||
//--Read Query Response-- | ||
export function readQueryResponse(chainName, fileName) { | ||
return zone.readFromFile(chainName, queryResponsesDirectoryName, fileName); | ||
} |
Oops, something went wrong.