0

I am new to java script and node JS. I am trying to create a simple app where the user can convert currency values by entering the amount and the currency type. i checked this API request its working fine, but i have no idea how to use html input tag to get the inputs and send it to the API request form.

var unirest = require("unirest");

var req = unirest("GET", "https://currency-exchange.p.rapidapi.com/exchange");

req.query({
    "q": "1",
    "from": "USD",
    "to": "LKR"
});

req.headers({
    "x-rapidapi-host": "currency-exchange.p.rapidapi.com",
    "x-rapidapi-key": "1599d15183msh1ede0c59134d7c4p1c921bjsnedcdcb4dded9"
});

req.end(function (res) {
    if (res.error) throw new Error(res.error);

    console.log(res.body);
});

1 Answer 1

2

Node.js is not a web browser. It doesn't have input tags.

If you want to communicate between a browser and Node.js then you'll need to create some kind of connection between them.

Typically this would involve writing a web service using Node.js (e.g. with the Express module) and then communicating to it with a form submission or with an Ajax request.

Alternatively, you could bundle Node.js and the browser together into a single app. Electron is a populate framework for doing that.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.