Html SyntaxError:我的简单节点应用程序中JSON输入意外结束..无法获取数据

Html SyntaxError:我的简单节点应用程序中JSON输入意外结束..无法获取数据,html,node.js,express,heroku,Html,Node.js,Express,Heroku,这是服务器端!!我正在使用express server,在heroku上部署时,它无法按预期工作 const express = require("express") const app = express(); let PORT = process.env.PORT || 3000; app.use(express.static("./public")); app.use(express.json())

这是服务器端!!我正在使用express server,在heroku上部署时,它无法按预期工作


    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/")
    })


    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 "
    }})

一个客户端


    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/")
    })


    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 "
    }})

在这里,我使用highcharts将数据投影成图形形式。。 在localhost中它工作,但在部署中它不工作,请有人帮助


    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/")
    })


    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 "
    }})