Skip to content
Permalink
Browse files
Merge pull request #2 from web/master
adding the readline from origin to fork
  • Loading branch information
kluzikp committed Oct 11, 2019
2 parents eb37c21 + 87c1585 commit bc5b5cbe090915e0a401a93d5a12cd8135b5a866
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
@@ -2,6 +2,8 @@
'use strict'

const request = require('request')
const readline = require('readline')

const baseURL = 'https://api.exchangeratesapi.io/latest'

async function main() {
@@ -10,17 +12,21 @@ async function main() {
await checkValidCurrencyCode(base)
const data = await getData(`${baseURL}?base=${base}`)
await printObject(data)
const to = await getInput('convert to')
console.log(to)
process.exit()
} catch (err) {
console.log(`error: ${err.message}`)
}
}

const getInput = prompt => new Promise( (resolve) => {
process.stdin.resume()
process.stdin.setEncoding('utf8')
process.stdout.write(`${prompt}: `)
process.stdin.on('data', text => resolve(text))
const getInput = prompt => new Promise(resolve => {
const read = readline.createInterface({ input: process.stdin, output: process.stdout })
read.question(`${prompt}: `, value => {
console.log(`You entered ${value}`)
read.close()
resolve(value)
})
})

const checkValidCurrencyCode = code => new Promise( (resolve, reject) => {
@@ -34,6 +34,7 @@
"koa-static": "^5.0.0",
"koa-views": "^6.1.5",
"mime-types": "^2.1.22",
"readline": "^1.3.0",
"readline-sync": "^1.4.10",
"request": "^2.88.0",
"sqlite-async": "^1.0.11"
@@ -2,13 +2,17 @@
'use strict'

const request = require('request')
const readline = require('readline')

const baseURL = 'https://api.exchangeratesapi.io/latest'

const getInput = prompt => new Promise( (resolve) => {
process.stdin.resume()
process.stdin.setEncoding('utf8')
process.stdout.write(`${prompt}: `)
process.stdin.on('data', text => resolve(text))
const getInput = prompt => new Promise(resolve => {
const read = readline.createInterface({ input: process.stdin, output: process.stdout })
read.question(`${prompt}: `, value => {
console.log(`You entered ${value}`)
read.close()
resolve(value)
})
})

const checkValidCurrencyCode = code => new Promise( (resolve, reject) => {

0 comments on commit bc5b5cb

Please sign in to comment.