0

I am trying to write the javascript version of this Github bash script

I need a for loop to go through an API endpoint and find the first response with the result '0'.

The API URI stays the same but has an increasing query string salaryrange.

I have tried to code this but it appears to be in async.

function seekSalaryFinder() {
  var min = 30000
  var max = 200000
  var salary = min;
  for (t = 0; t <= 30; t++) {
    var salary = salary + 10000
    var apiEndpoint = 'https://chalice-search-api.cloud.seek.com.au/search?jobid='
    var jobId = 38300301
    var url = apiEndpoint + jobId + "&salaryrange=" + salary
    request.get(url, function(error, response, body) {
      var array = JSON.parse(body);
      console.log(array.totalCount)
    });
  }
}

Can someone please help me and explain to me what would be the best way to approach this?

turtlepower
  • 708
  • 1
  • 7
  • 18

0 Answers0