Skip to content

Instantly share code, notes, and snippets.

@wallin
Created October 9, 2013 08:43
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wallin/6898209 to your computer and use it in GitHub Desktop.
Save wallin/6898209 to your computer and use it in GitHub Desktop.
Getting raw text response from Angular JS $http
# 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