diff --git a/content/_code-samples/markers-and-pagination/js/pagination-with-markers.js b/content/_code-samples/markers-and-pagination/js/pagination-with-markers.js index 4830ecaaa6..134f3ddf19 100644 --- a/content/_code-samples/markers-and-pagination/js/pagination-with-markers.js +++ b/content/_code-samples/markers-and-pagination/js/pagination-with-markers.js @@ -2,22 +2,22 @@ const xrpl = require("xrpl") async function main() { - // Create client and connect to network. + // Create a client and connect to the network. const client = new xrpl.Client("wss://xrplcluster.com/") await client.connect() - // Query ledger data. + // Specify a ledger to query for info. let ledger = await client.request({ "command": "ledger_data", "ledger_index": 500000, }) - // Create function to loop through API calls. + // Create a function to run on each API call. function code(){ console.log(ledger["result"]) } - // Run code at least once before checking for markers. + // Execute function at least once before checking for markers. do { code() @@ -25,6 +25,7 @@ async function main() { break } + // Specify the same ledger and add the marker to continue querying. const ledger_marker = await client.request({ "command": "ledger_data", "ledger_index": 500000, @@ -34,6 +35,7 @@ async function main() { } while (true) + // Disconnect when done. If you omit this, Node.js won't end the process. client.disconnect() } diff --git a/content/_code-samples/markers-and-pagination/py/pagination-with-markers.py b/content/_code-samples/markers-and-pagination/py/pagination-with-markers.py index c633ca222c..a8e4e98f83 100644 --- a/content/_code-samples/markers-and-pagination/py/pagination-with-markers.py +++ b/content/_code-samples/markers-and-pagination/py/pagination-with-markers.py @@ -1,23 +1,23 @@ from xrpl.clients import JsonRpcClient from xrpl.models.requests import LedgerData -# Create a client to connect to the main network. +# Create a client to connect to the network. client = JsonRpcClient("https://xrplcluster.com/") -# Specify ledger to query and request data. +# Specify a ledger to query for info. ledger = LedgerData(ledger_index=500000) ledger_data = client.request(ledger).result -# Code to run on each call. +# Create a function to run on each API call. def code(): print(ledger_data) -#Execute code at least once before checking for markers. +# Execute function at least once before checking for markers. while True: code() if "marker" not in ledger_data: break - # Specify ledger and marker to continue querying. + # Specify the same ledger and add the marker to continue querying. ledger_marker = LedgerData(ledger_index=500000, marker=ledger_data["marker"]) ledger_data = client.request(ledger_marker).result \ No newline at end of file diff --git a/content/references/http-websocket-apis/api-conventions/markers-and-pagination.md b/content/references/http-websocket-apis/api-conventions/markers-and-pagination.md index 4b62e289c8..c73a4fe5f2 100644 --- a/content/references/http-websocket-apis/api-conventions/markers-and-pagination.md +++ b/content/references/http-websocket-apis/api-conventions/markers-and-pagination.md @@ -19,4 +19,4 @@ _JavaScript_ {{ include_code("_code-samples/markers-and-pagination/js/pagination-with-markers.js", language="js") }} - + \ No newline at end of file