Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我发现了 Dart 并用它开发了一个 Rest Server。我的理解future是一个很酷的异步回调函数,但我不明白它是如何从响应中写入数据的。
future
我不是在谈论客户端,我的代码如下所示:
getData(HttpRequest request) { dao.findAll().then((value) { print(value); }); }
该值已正确打印,现在如何将其返回request.response.write?
request.response.write
预先感谢您的回答。
您可以request.response.write在值处理程序中使用:
getData(HttpRequest request) { dao.findAll().then((value) { request.response ..statusCode = HttpStatus.OK ..write(value) ..close() ; }); }