localhost is whatever device the app is running on, so it’s generally not what you want to be using. Pick a real hostname or IP address. Incidentally, you have a lot of spurious code here: you don’t need custom headers, you don’t need a RequestOptions, you don’t need to manually stringify anything. Just pass an object and Angular will take care of all of that.
Remove all these unnecessary code, do a ifconfig(mac) or ipconfig(windows) take your network ip, connect device to the same wifi/network you are with the pc you are running the server and it will work
you don’t have any route??? like http://192.168.XX.X:3000/api/login or something like that? I think that you getting a 404 because there’s no route for root /
Step 1: Add a GET endpoint to your server, just make it return a string or anything. Hit that from your regular browser and make sure it exists.
Step 2: Forget completely about Ionic and use POSTman to post data to your server. It’s a free app/chrome extension that lets you make http requests.
Step3: Try hitting that GET endpoint you added to your server within your Ionic app.
You could have any of a large number of different problems. Try those above steps and see if you can get any of them to work.
Step 1: GET is working fine. I’ve tried it before using folder path and localhost as well.
Step 2: POSTman chrome extension. I’ve tried. Working without issues.
Step 3: Working.
Wow…if all of those work…I have no idea why your post wouldn’t work. It’s nothing to do with localhost vs your network IP because your get request worked, so that’s irrelevant. You clearly have a POST endpoint if postman was able to post to it and get a response back.
So…no idea. Compare the request and request headers that you have in POSTman with the request and request headers that are being sent in Ionic (use chrome network tab in debug window). Post images on here of what your successful request in postman looks like (including the headers) and do the same for your ionic app.