Power BI M looping code

I wrote the following code in M to handle the pagination from Power BI and the Bubble REST DATA API. I hope this helps others. Unfortunately the forum post stripped my indentation. Hopefull your familial enough with M code to fix this this

let
url = “YOUR URL”,
auth_token = YOUR TOKEN",
headers = [
#“Authorization”= "Bearer " & auth_token,
#“Content-Type”=“application/json”
],
options = [
Headers = headers
],
getNextPage = (startCursor) =>
let
urlWithCursor = url & “?cursor=” & Text.From(startCursor),
response = Web.Contents(urlWithCursor, options),
json = Json.Document(response),
results = Record.FieldOrDefault(json[response], “results”, {}),
remaining = Record.FieldOrDefault(json[response], “remaining”, 0),
nextCursor = startCursor + 100
in
[results = results, remaining = remaining, nextCursor = nextCursor],
allResults = List.Generate(
() => [results = {}, remaining = 1, nextCursor = 0, startCursor = 0, count = 0],
each (List.Count([results]) > 0 or _[remaining] > 0) ,
each getNextPage([nextCursor]),
each [results = _[results], remaining = _[remaining] , nextCursor = _[nextCursor]]
),
jsonColumn = List.Transform(allResults, each _[results]),
combinedResults = List.Combine(jsonColumn),
table = Table.FromRecords(combinedResults)
in
table