response.text -> response.body
See original GitHub issueimport Koa from 'koa';
import Router from 'koa-router';
export default async function(config: Configuration) {
const router = new Router();
router.post('/abcdefg', async ({
request,
response
}) => {
response.body = '<Settlement><success_code>0</success_code></Settlement>';
response.set('Content-Type', 'application/xml');
response.type = 'application/xml';
response.status = 200;
});
return new Koa()
.use(router.routes())
.use(router.allowedMethods());
}
returns {}
where I expect <Settlement><success_code>0</success_code></Settlement>
this is because response.text has the value <Settlement><success_code>0</success_code></Settlement>
. response.body is {}
. How can I have the value in response.body?
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Response.text() - Web APIs - MDN Web Docs
The text() method of the Response interface takes a Response stream and reads it to completion. It returns a promise that resolves with...
Read more >javascript - Getting Text From Fetch Response Object
Using the fetch JavaScript API you can try: response.text().then(function (text) { // do something with the text response });. Also take a look...
Read more >response.text - Python requests
response.text returns the content of the response, in unicode. Basically, it refers to Binary Response content.
Read more >text - Velo API Reference
Reads the response body as a string. The text() function reads the body response stream to its completion and formats the data as...
Read more >Fetch
Response provides multiple promise-based methods to access the body in various formats: response.text() – read the response and return as text, ...
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 FreeTop 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
Top GitHub Comments
are you using supertest?
@dead-horse thanks! where should that parsing go? in supertest?