EXCEPTION: Response with status: 0 for URL: null


#1

test rest api app getting: EXCEPTION: Response with status: 0 for URL: null
Calling walmart api and work fine outside app but getting error.
Appreciate any help… Project link


#2

sound like CORS problem too me…

where do you face the problem? on every devices inclusive while debugging with ionic serve?


#3

launching it from cmd on windows using : ionic serve


#4

Well, have you try on android or iPhone, does it work? If yes, that is definitely a CORS problem

If you are using app-script < 0.0.42 you could bypass the CORS issue with ionic serve by using the Ionic proxy. Currently in 0.0.42 doesn’t work anymore


#5

let me try to build this as andiod app and ill will update


#6

Okay, for some reason i could not run this on emulator but there are two problems does look like cors issue and other main issue is the page(/src/pages/home/home.ts) constructor does not like the parameter:
constructor(public walmartService: WalmartService)
I tried building the tutorial test menu program and the pages have issue with constructor… any clue…

for Cors issue… trying to add to local project directory file ionic.config.jason file the following but still failing access control?
{
“name”: “ionic2-tutorial-github”,
“app_id”: “”,
“v2”: true,
“typescript”: true,
“proxies”: [
{
“path”: “/v1/”,
“proxyUrl”: “http://api.walmartlabs.com/vi
}
]
}


#7

The thing is, if it doesn’t work neither in emulator or on a device, except if you are using wkwebview, it might not be a cors problem.

About ionic.config.json, look at my msg above, currently app-script 0.0.42 and 0.0.43 I guess doesn’t support ionic.config.json, so trying to bypass the cors issue there right now won’t help


#8

I dont think this is the correct solution but I worked around the cross client issue -cors with chrome extension (access control) So now i dont get the 404 error.
The constructor issue was because import path was incorrect. Didnt get a warning from editor and app transpiled correctly, so assumed path was correct. In the end. just need to pay close attention to import path on service provider.
Uploaded working version to test working rest call to walmart api

Thanks for feedback


#9

Cool to hear you found a solution, well done!

For the future follow the issue above, actually when it’s supported and working the ionic proxy works really well with cors in browsers