Help me to display part of a API response

I’m using the frankfurter currency converter API
I am playing with APIs and creating a simple currency converter.
This takes 3 inputs AMOUNT, FROM, TO.
const endPoint = '

I have successfully returned this from xhr.response - Inputted values: 10, from = GBP to = EUR.


I can then console.log(xhr.response.rates.EUR) to get the EUR amount. This is only for this specific example. Is there any way to make this dynamic so that any to and from can be inputted.
Something like this?


You could try this (not sure if it is what you’re looking for):

let toCur = 'EUR';


You’ll have to change the hyperlink too to the currency you want to return, something like this (just an example):

let endPoint;
let toCur = 'EUR';
let fromCur = 'GBP';

function setValues(amount) {
    endPoint = '' + amount + '&from=' + fromCur + '&to=' + toCur;


You can also add the to and from currencies to the input parameters of the function if you want.