MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    expressApp.get - Error Cannot GET ...

    Scheduled Pinned Locked Moved Development
    4 Posts 2 Posters 956 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • spitzlbergerjS Offline
      spitzlbergerj Project Sponsor Module Developer
      last edited by spitzlbergerj

      Hi,

      I intercept a webservice call via node_helper.js. Now I wanted to handle two more webservice calls. Unfortunately this doesn’t work.

      my code:

      const NodeHelper = require("node_helper")
      var async = require('async');
      var exec = require('child_process').exec;
      var express = require('express');
      var app = express();
      
      ...
      
      module.exports = NodeHelper.create({
      	
      	start: function() {
      		//console.error('Starting node helper: ' + this.name);
      		var self = this;
      		
      		// Updateinterval ändern über Aufruf http://127.0.0.1:8080/MMM-CaravanPiPosition/changeUpdateInterval
      		this.expressApp.get('/' + this.name + '/changeUpdateInterval', function (req, res) {
      			res.send('Change UpdateInterval from '+ myUpdateInterval);
      			self.changeUpdateInterval();
      		});
      		
      		// Kalibrierung anzeigen über Aufruf http://127.0.0.1:8080/MMM-CaravanPiPosition/setCalibration
      		this.expressApp.get('/' + this.name + '/setCalibration', function (req, res) {
      			res.send('set Calibration');
      			valueListNHCaravanPiPosition[0]["cal"] = 1;
      		});
      		
      		// Kalibrierung löschen über Aufruf http://127.0.0.1:8080/MMM-CaravanPiPosition/unsetCalibration
      		this.expressApp.get('/' + this.name + '/unsetCalibration', function (req, res) {
      			res.send('unset Calibration');
      			valueListNHCaravanPiPosition[0]["cal"] = 0;
      		});
      	},
      ...
      

      The call of http://127.0.0.1:8080/MMM-CaravanPiPosition/changeUpdateInterval works as desired.

      The calls of http://127.0.0.1:8080/MMM-CaravanPiPosition/setCalibration and … unsetCalibration does not work.

      Instead the error message Cannot GET /MMM-CaravanPiPosition/setCalibration is displayed.

      what am i doing wrong? can’t several different webservice calls be processed?

      Thanks for every help

      Sepp

      Regards
      Josef

      http://www.spitzlberger.de/smartmirror, https://github.com/spitzlbergerj/MMM-TeslaLogger, https://github.com/spitzlbergerj/CaravanPi, https://www.la-gondola-barocca.de

      S 1 Reply Last reply Reply Quote 0
      • S Away
        sdetweil @spitzlbergerj
        last edited by

        @spitzlbergerj said in expressApp.get - Error Cannot GET ...:

        this.expressApp.

        where is expressApp set?

        typically it is

        const app = express()
          // setup the pattern you listen for
          app.get(url_pattern, (req,res) => {})
        

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        1 Reply Last reply Reply Quote 1
        • spitzlbergerjS Offline
          spitzlbergerj Project Sponsor Module Developer
          last edited by

          Hi Sam,
          yes, I had always asked myself that, but I am still a Javascript Newby. I got the code from a forum post. After it worked with the first pattern, I thought, that’s because of my low JavaScript knowledge.

          I have now changed it with your help. And now it works.

          Thank you very much!
          Sepp

          Regards
          Josef

          http://www.spitzlberger.de/smartmirror, https://github.com/spitzlbergerj/MMM-TeslaLogger, https://github.com/spitzlbergerj/CaravanPi, https://www.la-gondola-barocca.de

          S 1 Reply Last reply Reply Quote 0
          • S Away
            sdetweil @spitzlbergerj
            last edited by

            @spitzlbergerj cool!!

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Enjoying MagicMirror? Please consider a donation!
            MagicMirror created by Michael Teeuw.
            Forum managed by Sam, technical setup by Karsten.
            This forum is using NodeBB as its core | Contributors
            Contact | Privacy Policy