vuejs-templates/pwa

POST API not calling on mobile [Chrome v72.0.*]

iashraful opened this issue · 1 comments

Problem

  • I have a login api /api/login/
  • It's a POST api
  • Format is following
{
	"username": "user",
	"password": "pass"
}

When I'm trying on web[Desktop/Laptop] browser it's working fine for me. But when I'm trying on PWA mode on my phone[Chrome 72.0.3625.105] version. Then, it's not calling the API. I have tested so many ways. I found everything is working except the POST API call.

I have written code like following,

loginSubmit() {
	fetch('http://my-server.com/api/login/', {
		method: 'POST',
		headers: {
		  'Content-Type': 'application/json'
		},
		body: JSON.stringify(this.formData)
	}).then((response) => {
		return response.json()
	}).then((data) => {
		console.log(data)
		alert(data.success)
	})
}

Please let me know if I'm doing any mistakes

UPDATE It says network error. But I have active internet connection

I found the issue. It was related to my wifi router and localhost.