Return data from an API

Right now I’m running a flask app that is hosted on AWS. When I call my AWS endpoint by simply going to the html endpont, which looks like
blahblah.us-east-1.awsapprunner.com/someParameter/
the flask app will return a json list in the browser like below

[
  " Some sentence",
  " another sentence ",
  " and yet another sentence "
  ]

So, with that being said, I ultimately want to call this endpoint when a button is clicked, then return the data to some JS variable so I can ultimately do something with the data.

Psuedocode below

export function button2_click(event) {

    above_sentences = func_that_calls_endpoint_and_returns_above_json_list()

    console.log(above_sentences) # this should print the above json list, just so I can see that I actually have the list in a variable
}

EDIT 1:
I tried using
getJSON(“https://blahblah.us-east-1.awsapprunner.com/ass/”)
.then(json => console.log(json))
.catch(err => console.log(err));

But I get the error
TypeError: Failed to fetch

So I was running into an issue with CORS, which allows specific domains to access API’s on another domain. I’m running a flask app so I solved it by simply wrapping my flask app with flask_cors.

code example below.

from flask import Flask
from flask_cors import CORS
app = Flask(__name__)
CORS(app)

@app.route("/")
def helloWorld():
    return "Hello, cross-origin-world!"