Tried everything but the response doesn't get through! I can't find where I am wrong!
I have trouble with the fetch request. It's quite not working properly with FLASK localhost. I put a simple get request but all I get is an opaque response while logging on console. Though, just by going on the api endpoint, I am able to see the response.
.py(flask localhost)
from flask import Flask, render_template, request, jsonify
from flask_cors import CORS, cross_origin
app = Flask(__name__)
@app.route('/findHotels',methods = ['GET','POST'])
@cross_origin()
def findHotelsHelper():
    if request.method == 'GET':
        response = jsonify(message="Simple server is running")
        response.headers.add("Access-Control-Allow-Origin", "*")
        return response
if __name__ == '__main__':
    app.run(debug = True)
following is the code for html which is requesting data using fetch api
<!DOCTYPE html>
<html>
<body>
  <h1>Find Nearest Hotels in your Area! </h1>
  
  <form id="form1" action="http://localhost:5000/findHotels" method="GET">
      First name: <input type="text" name="fname"><br>
      Last name: <input type="text" name="lname"><br><br>
      <input type="button" onclick="loadDoc()" value = "GO">
  </form>
  
  <p id="demo"></p>
  
  <script>
  
      
  async function loadDoc(){
      await fetch('http://127.0.0.1:5000/findHotels', { method: 'GET', mode:'no-cors'})
          .then(function (response) {
            console.log(response);
            return response;
          }).then(function (text) {
            console.log('GET response:');
            console.log(text); 
          });
  }
  </script>
  
  </body>
</html>
Any suggestions would be very much appreciated. P.S. Sorry, I am new to stack overflow, forgive for not following proper rules for a post this while. Image showing working get request Image showing failed/(getting opaque) request if using fetch api Also I would like to point out, simple forms were also working fine and I was able to retrieve the json data but I want to do it without it and using JS only.
 
     
    