0

I'm trying to access the results from a pocket API call which requires posting to their domain. However, when I post, I get the issue

XMLHttpRequest cannot load https://getpocket.com/v3/get. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'localhost:3000' is therefore not allowed access. The response had HTTP status code 406. 

However, I've configured the httpProvider options to such.

$httpProvider.defaults.useXDomain = true; $httpProvider.defaults.withCredentials = true; delete $httpProvider.defaults.headers.common["X-Requested-With"]; $httpProvider.defaults.headers.common["Accept"] = "application/json"; $httpProvider.defaults.headers.common["Content-Type"] = "application/json"; 

I thought the configurations would allow the request to proceed, but they don't. I need a post request, so jsonp won't work. Any ideas would be much appreciated!

1 Answer 1

2

Try adding this line

$httpProvider.defaults.useXDomain = true; 
Sign up to request clarification or add additional context in comments.

5 Comments

Ah, are you using Chrome by chance? If so, have you tried on other browsers?
Yes I'm using chrome, anyway to fix it on chrome? Tried in firefox and same issue.
There's a known bug in Chrome stackoverflow.com/questions/21102690/…, here's a solution to that stackoverflow.com/questions/3102819/…
Ah gotcha that's VERY helpful. But how is my app supposed to work in chrome at all then if I need to make an api call to access another resource? As in if it's in production it'd work? Just not local development?
stackoverflow.com/a/6083677/3421811 is the answer I think you're looking for

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.