const axios = require('axios');
getprice = async () => {
let nsdq = await axios.get("https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol=IBM&apikey=e");
console.log(nsdq)
let share = nsdq.data['Global Quote']['01. symbol'] //ur infomartion
console.log(nsdq.data)
console.log(share)
price = document.querySelector('.nasdaqPrice')
price.innerText = String(share)
}
getprice()
this is share price which is IBM which is a string
i am also using browserify and if i change price.innertext = 'hi' it appears on the page
CodePudding user response:
Are your console logs showing any information?
I think you need to define getPrice, maybe like const getprice = async () => {...}
CodePudding user response:
ok i got your problem you have to pass responseType in second argument as config in you axios request so you will get json data in reponse
try you code this way
const axios = require('axios');
const getprice = async () => {
let nsdq = await axios.get("https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol=IBM&apikey=e", {
responseType: "json"
});
let share = nsdq.data['Global Quote']['01. symbol'] //ur infomartion
price = document.querySelector('.nasdaqPrice')
price.innerText = String(share)
}
getprice()