Problem receiving data usign http post

Hello! I have this error when execute my program:

“XMLHttpRequest cannot load No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:8100’ is therefore not allowed access.”

My function is like this:

 makePostRequest() {"", "Pepe&1234")
    .subscribe(data => {
        var alert = Alert.create({
            title: "Data String",
            subTitle: data.json().data,
            buttons: ["close"]
    }, error => {

Somebody know what is the problem?
Thanks in advance.

Best regards!!

your ionic app is running on “http://localhost:8100”, and since that is a different domain than the resource you are trying to access, the server is rejecting your request.

The code for your ionic app is probably fine, the server code is likely where the issue lies. I can’t look at your server code (and it isn’t my area of expertise anyway), but this kind of error is a CORS error, so googling how to fix that would be a good place to start.

best of luck :slight_smile:

Thanks for replying Jeffroylance! :slight_smile:
The question is that I can have communication client - server, but not server - client so… I don’t know why I can send a data to my server but not receiving the response.

Here my server code:

http.createServer(function (req, res) {

	var body='';
	req.on('data', function (data){
		body +=data;
		var POST = qs.parse(body);

	var client = new net.Socket();
	client.connect(1337, '', function() {

	client.on('data', function(data) {
		console.log('Received...: ' + data);
		client.destroy(); // kill client after server's response

	client.on('close', function() {
		console.log('Connection closed');

}).listen(8080, “”);