Alerts not working in ionic

This works fine on a browser but not in a capacitor app on an android device, ios not tested…
I wonder if this has to do with capacitor or something else. Hope someone can help me with this. Thanks in advance!

    var dataToSend = {

    var url = '';,{data:JSON.stringify(dataToSend)},{responseType: 'text'}).subscribe(
        this.message = data;
        if(data === "Logged In Successfully!")
        else if(data === "Welcome!")

I would recommend to use the IonAlert :blush:

It seems that alerts work, it’s the that doesn’t work on mobile…

I’m trying to do the same request with ionic advance HTTP but not sure how to convert it from angular http to ionic http
could u help me with that…

It has to be something like
return from (,{data:JSON.stringify(dataToSend)},{responseType: 'text'}) .pipe(map((data: any) => JSON.parse(data?.data)))

I think it’s a mistake to overengineer HTTP. Get it working with:

  • Angular HttpClient
  • never manually calling stringify or setting Content-Type headers
  • no any

If there are CORS problems, fix them on the server side instead of kludging around them on the client side.

Should I consider that there are CORS problems if I do get a response from get requests but not from post requests? If yes how to fix it?

The code in the Angular HttpClient works fine in the Browser… What should I change from the code in the question on the top to get it to work in android also?

Turns out @rapropos was right, there were CORS problems that I fixed but adding the code below on my node.js file

var app = express();
var cors = require('cors');
app.all('*', function(req, res, next) {
    var origin = req.get('origin'); 
    res.header('Access-Control-Allow-Origin', origin);
    res.header("Access-Control-Allow-Headers", "X-Requested-With");
    res.header('Access-Control-Allow-Headers', 'Content-Type');