here is the server side!!i am using express server and upon deploying it on heroku it doesnt work as expected.!!
const express = require("express")
const app = express();
let PORT = process.env.PORT || 3000;
app.use(express.static("./public"));
app.use(express.json())
const fs = require('fs');
let data = JSON.parse(fs.readFileSync('./public/data.json','utf-8'));
app.get("/extra/:year", (req, res) => {
let year = req.params.year;
res.json(data.extraRunsPerTeam2016[year])
})
app.get("/economy", (req, res) => {
if (!req.query.season1) {
return res.send(
{
error: "this is not the season"
})
}
console.log(data.economicalBowler2015)
res.send(
res.json(data.economicalBowler2015)
)
})
app.listen(PORT, () => {
console.log("server is up and running !! please check http://localhost:3000/")
})
one of the client side!
function show() {
let year = document.getElementById("season").value;
if (year == "") {
alert("please select SEASON from the drop down list ")
}
// fetch('/extra?season=' + year)
fetch(`/extra/${year}`)
.then((resp) => resp.json())
.then(resp => {
// visualizeData(resp);
setTimeout(function(){ return visualizeData(resp); }, 3000);
function visualizeData(data) {
let a = [];
for (let i in data) {
a.push([i, data[i]])
}
Highcharts.chart("extra-Runs", {
chart: {
type: 'column'
},
title: {
"its completed "
}})
here im using highcharts to project the data into graph form.. in localhost its working but on the deployment its not working please someone help!!