Created
October 9, 2013 08:43
-
-
Save wallin/6898209 to your computer and use it in GitHub Desktop.
Getting raw text response from Angular JS $http
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you have an API that returns JSON but want the reponse as raw text you | |
# can override Angulars built in JSON response parser by using an identity | |
# function as response transformer function | |
$http.get("/myapi", | |
{ transformResponse: (d, h) -> return d } # return raw response | |
) | |
.success((data, status, headers) -> | |
# data is now pure text | |
alert("Response is text: #{angular.isString(data)}") | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment