I'm trying to fetch a string from a URL and print it in the console, here's the code:
function myFunction() {
const url = 'http://127.0.0.1:5000/' + makeOutputId + "," + modelOutputId + "," + userInputYear + "," + userInputTransmissionId + "," + userInputFuelTypeId
+ "," + userInputEngineCapacity + "," + userInputMileAge;
console.log(url);
fetch(url)
.then(function (response) {
response.text().then(function (text) {
storedText = text;
console.log(storedText);
});
});
}
When I just click on the URL, it works but when I try fetching it I'm getting the error mentioned in the title. Is there anything wrong with my code? I tried going through other answers from similar questions but none of them was helpful.