Hey, everyone!
So I’ve run into a bit of a roadblock as I build out a small Angular app for a Christmas initiative we’re doing.
One of the components is allowing people to submit a story, so - to keep life a bit simpler - I thought I’d just use a FormStack. We use them for lots of things, but this would be the first time trying to use their API.
Their API seems straight-forward enough, nothing too crazy, so I start to build the app, get everything working as I want it to and test with a local JSON response. We’re all good.
Then I try to make the call to FormStack’s API. Using the examples and generated API call, I test it in my browser. I can navigate to the JSON response just fine, so I try to use $http.jsonp, knowing that it will be a cross-platform response:
$http.jsonp(url, { jsonCallbackParam: 'callback' }).then(...)
That’s when I run into trouble. Either I’m doing something incorrectly or FormStack is sending back an improper response. The browser throws a Syntax error because it’s looking for a JSONP response, but it’s getting a pure JSON response. Essentially, the response is not being wrapped in a JavaScript function as expected.
So, I thought I’d try just $http.get(…), but that doesn’t work either. Then I get no response, which makes sense.
Am I missing something here? I’m not really sure what else to try, unless the issue is on their end and not mine?
Is there a way to “trick” Angular to be okay with a plain JSON response. I think I know a trick to do that in jQuery, but I’m trying to avoid that, if possible.
Thanks!
-Eric