Stuck on Currency Converter

Hello,

I’m working through the ‘Getting Started with Velo’ exercises and I cannot get the currency converter to work.

My code is as follows.

import { getJSON } from ‘wix-fetch’ ;

const url = “https://api.exchangeratesapi.io/latest” ;

let currencyOptions = [
{ “value” : “USD” , “label” : “US Dollars” },
{ “value” : “EUR” , “label” : “Euros” },
{ “value” : “JPY” , “label” : “Japanese Yen” },
]

$w . onReady ( function () {
populateDropdowns ();
$w ( ‘#calculateButton’ ). onClick (( event ) => {
calculateCurrency ();
})
});

function populateDropdowns () {
$w ( ‘Dropdown’ ). options = currencyOptions ;
$w ( ‘Dropdown’ ). selectedIndex = 0 ;
}

function calculateCurrency () {
let initialAmount = $w ( “#sourceAmount” ). value ;
let sourceSymbol = $w ( “#sourceCurrency” ). value ;
let targetSymbol = $w ( “#targetCurrency” ). value ;
let fullUrl = ${ url } ?base= ${ sourceSymbol } &symbols= ${ targetSymbol } ;
getJSON ( fullUrl )
. then ( json => {
$w ( “#targetAmount” ). value = initialAmount * json . rates [ targetSymbol ];
})
}

I have carefully named all of the elements as shown in the tutorial and double checked many times.

The console log in Chrome AND Wix’s Site Events say " Uncaught (in promise) TypeError: Cannot read property ‘JPY’ of undefined"

It is the same for USD and EUR. When I hove over “#targetAmount” it tells me that you cannot convert numbers to strings.

I’m really lost and even when I copy and paste the code it doesn’t work. The console log is telling me the error is on line 30. Any and all help is greatly appreciated.

Thank you!

So I did a little more digging and here is what I found.

I followed the URL https://api.exchangeratesapi.io/latest and it takes you to a 101 error message stating that there is no access key.

So, I tried going to https://api.exchangeratesapi.io which automatically redirects you to [https://apilayer.com/](https://apilayer.com/

After)

They do offer support for currency exchanges, but when you click on the link to the currency exchange API it takes you to https://currencylayer.com/

It seems like the correct reference is https://api.currencylayer.com/live in combination with an access key. I replaced the tutorial URL with the api.currencylayer URL in various forms but no dice. It keeps asking me for an access key.

Does the API URL need to be updated or am I missing something?

Thanks again!

It looks like I am too late to edit my previous post… whoops.

However, I looked into the 101 error code I kept getting.

According to MDN, 101 is a protocol switch asking for the HTTP header to be Upgraded (i.e., updated) . Please correct me if I am wrong, but this means that the server-side header would need to be updated to accommodate the changes and do not believe Velo users have access to the back-end headers, but please correct me if I am wrong.

Can I please request this be fixed ASAP or receive instructions on how to do so myself?

Thank you!

Perhaps this can help you…
https://www.wix.com/velo/example/currency-converter