Wrong Response.text() behavior
See original GitHub issueTrying to get a simple string from a REST-API using the Angular’s Http.get()
, but having an unexpected trouble while trying to get the Response’s body, using Response.text()
:
Expected response:
16288083cbfe40da68c4674b704c675f
Actual response:
<66363332 37303033 62306262 38646366 61356236 62353230 37616535 35613762>
I assume the problem is that the response from the server is not a JSON, nor HTML, but a plain text string and looks like it is stored internally using NSData
, and there might be something wrong during string extraction from NSData
.
versions: Angular 2.0.0-rc.4 TNS-core: 2.1.1 NativeScript-Angular 0.2.1
Issue Analytics
- State:
- Created 7 years ago
- Comments:20 (5 by maintainers)
Top Results From Across the Web
Error Messages: Examples, Best Practices & Common Mistakes
Error message best practices. Good error messages and bad ones result in wildly different user behavior. Read this anecdote from UX pro Jennifer ......
Read more >Handling Failed HTTP Responses With fetch() - TJ VanToll
Per MDN, the fetch() API only rejects a promise when a “network error is encountered, although this usually means permissions issues or similar....
Read more >JavaScript fetch - Failed to execute 'json' on 'Response'
Response methode like 'json', 'text' can be called once, and then it locks. The posted image of response shows that body is locked....
Read more >511289 - Non-ASCII characters not encoded correctly in Fetch ...
Issue 511289: Non-ASCII characters not encoded correctly in Fetch API's Response.text(). Reported by schedule a_deleted_user a_deleted_user.
Read more >What happens when you read a response? - JakeArchibald.com
There's a bit of disagreement over the behaviour of requests and responses in the fetch API, curious to know what you think…
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@chiefmc After some investigation: What you are seeing is actually toString-ed NSData of the response. There is a pending fix: NativeScript/NativeScript#2487
There is a workaround(not very pretty though). Get the response body and call IOS native API to convert it to string:
I must mention, that the same code works perfectly in Android environment. So the problem most probably lies somewhere in-between NS and iOS