简体   繁体   中英

How do I fix net::ERR_SSL_PROTOCOL_ERROR caused by my js code

I'm currently having an issue when I call certain function repeatedly (ChartData). The code that calls the function is as follows:

  for (let i = 1; i < 3600; i++) {
    setTimeout(function timer() {
      chartserviceApi.ChartData("false").then(responseArr => {
       
        console.log("Here !")
        Chartdata = responseArr.data
        let prpdData = responseArr.data.slice();
        if (Chartdata.length == 0) {
          dataPresent = false;
        }
        if (responseArr.data.find(x => x > 200)) {
          alert('abv 200');
        }

        prpsch1.streamPush(responseArr.data)
        prpdch1.streamPush(prpdData)

        
        const parsedMessage = responseArr.data
        const keys = Object.keys(parsedMessage)
        let dataPackage = parsedMessage[keys[keys.length - 1]]
        console.log(dataPackage)
        //prpsch1.streamPush(dataPackage[0]);
        prpdch1.streamPush(dataPackage[0]);
        prpsch1.consume();
        prpdch1.consume();
        prpsch1.runStream();
        prpdch1.runStream();
      });
    }, 4000);}

The ChartData function is as the following:

import axios from 'axios';
const Chartdata = 0
export default {
  ChartData(param) {
    if (param == "false") {
      console.log("False!")
      return axios.get('https://localhost:3000/api/Sensor/GetSensorDataQ?id=1&isInitiated=false');
    }
    else {
      console.log(param)
      console.log("True!")
      return axios.get('https://localhost:3000/api/Sensor/GetSensorDataQ?id=1&isInitiated=true');
    }
  }

Then I get these errors repeatedly. 在此处输入图像描述

Can anyone suggest what to do here?

Thanks a lot in advance:)

Change https protocol with http in your url. Because https protocol need ssl certificate.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM