Is it possible to return the response data as a string?
See original GitHub issuemock.onGet('/api').reply(200, '{"test": 5}')
response.data is a JS object that looks like {test: 5} instead of a string.
Is there any way to force the response to be a string?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:6 (1 by maintainers)
Top Results From Across the Web
How to return string as a response to http request
It seems $http finds it difficult to parse the invalid JSON data in the response. We have produces = {MediaType.
Read more >Response.text() - Web APIs - MDN Web Docs
It returns a promise that resolves with a String . The response is always decoded using UTF-8. Syntax. text()
Read more >How to store Response.ok().built result into a String variable
Just return Response object as your method was supposed to return Response object.
Read more >Reading an HTTP Response Body as a String in Java
We can retrieve and send data via the CloseableHttpClient class. To create an instance of it with the default configuration, we can use...
Read more >Describing Responses - Swagger
A response is defined by its HTTP status code and the data returned in ... JSON is the most common format for data...
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

i’d also like to use an array instead of an object. The second parameter of reply should be any type
This won’t work if the
transformResponseis the thing you want to test.At the moment, it appears a custom transformResponse on the request is called, but the data isn’t passed to it. I’m going to investigate further.