We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import { createServer, fetch } from 'http'; createServer((req, resp) => { req.on('data',async (body) => { if(req.url == '/wait'){ print("fetch..."); let response = await fetch('http://127.0.0.1:8001/echo', { method: 'POST', body: 'hello server' }) let result = await response.text() print("fetched:",result); resp.end(result) }else{ resp.end(body) } }) }).listen(8001,'0.0.0.0', () => { print('listen 8001 ...\n'); }) async function test_fetch() { let resp = await fetch('http://127.0.0.1:8001/wait', { method: 'POST', body: 'hello server' }) print('fetch client recv:', await resp.text()) print() } async function run_test() { await test_fetch() exit(0) } run_test()
Output after execution.
wait... fetched: hello server
No output fetch client recv:hello server
fetch client recv:hello server
So, after adding async/await operations to the http server, the request cannot get a response.
To return an empty response using CURL.
curl -d 'hello server' http://127.0.0.1:8001/wait -X POST curl: (52) Empty response from the server
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Output after execution.
No output
fetch client recv:hello server
So, after adding async/await operations to the http server, the request cannot get a response.
To return an empty response using CURL.
The text was updated successfully, but these errors were encountered: