Read the statement by Michael Teeuw here.
expressApp.get - Error Cannot GET ...
-
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
-
@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) => {}) -
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 -
@spitzlbergerj cool!!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login