I'm getting TypeError: response.json is not a function error. Can someone please point me in the right direction.


Joined
Mar 10, 2021
Messages
1
Reaction score
0
var url = "https://api.exchangeratesapi.io/latest?base=";
async function convert(){
var base = document.getElementById('Base').value;
var out = document.getElementById('Output').value;
var amount = document.getElementById('Amount').value;
var finalValue;
let response = await fetch(`${url}${base}` ,{method:'GET'})
let data = await response.jason()
finalValue = data.rates

finalValue = finalValue[out]*Number(amount);
var result = `Converted Amount of ${amount} ${base} is ${finalValue} ${out}`
document.getElementById('Converted').innerText = result;
}
 
Ad

Advertisements

Joined
Nov 27, 2019
Messages
155
Reaction score
23
This looks like a framework of some kind. You need to say what that framework is to get help, because itnees someone other then someone that knows JavaScript to answer it. BUT is this line:
let data = await response.jason();
wrong?
Don't you want
response.json(); NO A

.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top