I set up an action function in routes/tryingSomething.js
actions:{
GetSquare: function(){
var self = this;
var num=document.getElementById("Number").value;
console.log(num);
self.get('ajax').request('findSquare', {
data: {
// filename1: x,
"inputNum": num
},
timeout: 20000
// console.log(11)
}).then(response => {
var a = response;
console.log(a);
});
}
}
This calls server/index.js
var express = require('express');
// usual stuff that was inbuilt while generating server 'ember g server index'
// and then ....
var router = express.Router();
router.use(bodyParser.json());
router.use(bodyParser.urlencoded({
extended: true
}));
router.get('/findSquare',function(req,res){
console.log('####');
res.status(200).json(25);
});
};
- on running the server and sending value to the server, it says resource not found on the console
- on running the server and trying url '
localhost:4200/findSquare?inputNum=5
I'm getting 200 in terminal, while I'm not getting the '####' which i printed in the route.get('/findSquare') function. Now on terminal both are calling the same route, but one says 404 and the other, 200.
on running from controller action,
GET /findSquare?inputNum=5 404
on running from browser directly
GET /findSquare?inputNum=5 200
Aucun commentaire:
Enregistrer un commentaire