What is the best way to persist in asking until getting a specific response?

I am struggling to create code that iterates through a query until the desired result is achieved. Let's say I make this request:

{{API host}}/{{APP ID}}/{{REST API}}/hive/Management/set/keys?filterPattern=*&pageSize=5&cursor=0

The response from the server is:

{
    "keys": [],
    "cursor": "252"
}

Then, I take the value of cursor="252" and include it in the next query

{{API host}}/{{APP ID}}/{{REST API}}/hive/Management/set/keys?filterPattern=*&pageSize=5&cursor=252

This process should continue until the server responds with cursor="0"

I have been stuck on this problem for four days and I'm running out of ideas. Maybe implementing a while loop could help me solve it? Any assistance would be greatly appreciated.

Answer №1

My personal solution:

const data = pm.response.json();

if(data.pointer !== "0"){
    postman.setNextRequest("Your Request")
    pm.test('Pointer is not 0', () => {
        pm.expect(data.pointer, 'Error').to.not.eql("0")
    })
} else {
pm.test('Pointer is ' + data.pointer, () => {
    pm.expect(data.pointer).to.eql("0")
})
}

Hopefully this method can assist someone else

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Sending numerous array values from datatables

I am currently working with datatables that allow for multiple selections. When I select 3 rows from top to bottom (as shown in this picture), the console.log returns this specific value for each row selected. The value that needs to be passed to the next ...

Using React js to transform objects into arrays for useState

Hey there! I'm currently working on a webshop demo project for my portfolio. I've encountered an issue while trying to fetch data from commerce.js. The data is in the form of objects, which are causing problems when I try to map them. I've a ...

What Could be causing the Electron Vibrancy Effect to be malfunctioning?

This issue is really baffling me because I can't pinpoint where the problem lies. In my previous project using older versions of Electron on the same machine, everything worked fine when I used vibrancy. But now, it's not working and I have no c ...

Setting state inside the callback function of setState is causing issues with the state not being updated correctly

Having 2 list items, both utilizing the <ListItem /> component with this.props.a = true and this.props.b = true being passed down from their parent components. It's worth mentioning that there are 2 list items in order to ensure that each of the ...

Why isn't my Python script writing to a JSON file when run using a batch file?

I am facing an issue with my Python script that involves web scraping and saving data to a JSON file. The script works perfectly when executed manually through the command line interface. However, when run from a batch file triggered by a task scheduler, t ...

How can I enable form submission in jQuery while overriding the preventDefault function?

I created a function to validate that at least one form field is filled out: function checkFields(form) { var checks_radios = form.find(':checkbox, :radio'), inputs = form.find(':input').not(checks_radios).not('[ty ...

Interact with a webpage element that is nested within another element using JavaScript

<div _ngcontent-tbs-c102="" class="tbis-div"><div _ngcontent-tbs-c102="" tabindex="0" class="hidden-xs" aria-label="2. Result for and displayed for your query"><span _ngcontent ...

I am interested in a Javascript library that utilizes require(), yet I do not possess or utilize nodeJS

As I've delved into various JavaScript projects and libraries, I've come across the require() function used to import other files like this: require('somefile') This is something associated with node.js, a platform that I am not famil ...

Utilize Angular2 with ES6 modules while running an Express server

Having some issues using ES6 Modules with Angular2 in an app served by Node.js and Express.js. When attempting to load the Angular2/ES6 app in browser, encountered this error message in the FireFox console: The stylesheet http://localhost:8080/boot.css w ...

Calculate the total of the smallest values in three columns as they are updated in real-time

I'm facing an issue with dynamically adding the sum of the 3 lowest values entered in columns. The Total Cost Field is not displaying any value, and changing the type from number to text results in showing NaN. I've tried various approaches but h ...

How can one effectively access a nested JSON value in Angular by concatenating all fields?

If we have a JSON stored in the variable person like below: { "firstName": "First Name", "lastName": "Last Name", "address": { "city": "New-York", "street": "Some Street" } } To access the value of street, we would typical ...

The new and improved Vue 3 computed feature in the Composition API

The temporary object appears as: tmp : { k1: { k2 : { k3 : [abc, def] } } To access k3 in the setup, it should be: tmp.value.k1.k2.k3[0 or 1]. I am looking to change its name to something like - k3_arr = tmp.value.k1.k2.k3; Within my Vue single componen ...

Changing json into another format

I am struggling with a JSON data format issue. I have tried using Object.values and object.keys along with Array.prototype.map(), but my algorithm is not producing the desired outcome. [ { "2018-01-01": [ { "firstname": "mati", "lastname": "mati ...

Struggling to manage texbox with Reactjs

Currently working in Reactjs with Nextjs and encountering a problem with the "text box". When I use the "value" attribute in the textbox, I am unable to input anything, but when I use the "defaultValue" attribute, I receive a validation message saying "Ple ...

Turning On and Off Hover Effects in AngularJS

I am looking to implement a feature that enables and disables the hover state on an element based on certain conditions. As a newcomer to Angular, I am unsure of how to approach this and haven't been able to find a solution online. Here is a sample o ...

How to incorporate Base64 textures into Three.js

I am currently trying to load textures from URLs, but since my backend code is generating planets, I need to display them using Base64 instead. I'm experimenting with procedural generation, so I'd rather not save the image and then load it via U ...

Is it possible to achieve the full image when utilizing double buffering for drawing on canvas?

I have a code where I am using two canvas elements to draw an image in order to prevent flickering. However, I am facing an issue where I cannot get the full image to display when using this method. When I use just one canvas, the image displays fine. It ...

Interacting with individual divisions on a leaflet map

I've been facing a challenge with this interaction for some time now, and finding the appropriate solution seems quite daunting at the moment. Recently, I created a map with basic points using GeoJSON format (generated with PHP & MySQL). I'm cur ...

I'm looking to filter this array based on the value of a subarray that the user will specify the key and value for. How can I accomplish

Given the input var key="value_0" and var input="hello", I need to filter the array in TypeScript based on these values. The filtering criteria involve checking if the array elements contain a subarray with key="value_0" and if the value of this key includ ...

Struggling with making JSON.parse() function properly in a Discord Bot

I have a separate JSON file connected like this const Players = require('./Database/Players.json'); and a parser that handles the code client.on('message', message => { if (message.content.toLowerCase() ==='smack activate ...