Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 228595

Ionic + Express 4

$
0
0

My angular project ist running on port 8100 and the Express 4 server uses port 8080.
How to make cross-domain access possible?

I added the following lines to my server.js (Express 4):

app.use(function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
  next();
});

customersFactory.js

var path = 'http://localhost:8080';

  factory.getCustomers = function() {
    return $http.get(path + '/customers');
  };

  factory.getCustomers = function(customersId) {
    return $http.get(path + '/customer/' + customersId);
  };

The following error occurs:

GET http://localhost:8080/customer/undefined 404 (Not Found)


Viewing all articles
Browse latest Browse all 228595

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>