Reputation: 77
I am unable to request JSON from HTML using request.
I am using the request package from npm.
<!DOCTYPE html>
<html lang="en">
<head>
<title>MySite!</title>
</head>
<body>
<h2>
its ya boi
</h2>
<button onclick=ree>workkkkk</button>
<script>
const request = require('request')
function ree() {
request('https://api-quiz.hype.space/shows/now',(error,response,body) => { //requests data from the hq trivia api
//bodys = JSON.parse(body)
//document.getElementById("para").innerHTML = (bodys.nextShowPrize)
//console.log(`Next game: ${body.nextShowTime}`)
alert(body)
})}
</script>
</body>
</html>
Upvotes: 0
Views: 66
Reputation: 6882
You could use fetch
.
fetch('https://api-quiz.hype.space/shows/now')
.then(res => res.json())
.then(console.log)
Upvotes: 1