The problem with the code is that the crawl_url.trigger() function is asynchronous. This means that it returns control to the code before it is finished executing. As a result, the jsonArray.push() statement is executed before the crawl_url.trigger() function has finished fetching the data.
To fix this, you need to use the await keyword to wait for the crawl_url.trigger() function to finish executing before executing the jsonArray.push() statement.
Here is a modified version of the code that should work:
Which method you choose to use is up to you. The promise chain method is more explicit and easier to read, but the async/await method is more concise and easier to write.