HTTPRequest.request with sendData, can't seem to get this to work

折月煮酒 提交于 2019-12-24 12:15:30

问题


I'm trying to wrap my head around Dart, and in doing so got stumped with adding some data to an HTTPRequest. I need to send a parameter with this request, so I figured the "sendData" variable would probably help me do that. Documentation is sparse at best for this method, so for all I know it's just my syntax that's wrong. Any idea why this wouldn't work?

HttpRequest.request(url, sendData:{"rnd":rnd.millisecondsSinceEpoch}).then(onLoadSuccess).catchError(onLoadError);

Currently it tanks out in html_dartium.dart at

void send([data]) native "XMLHttpRequest_send_Callback";

And only tells me "String expected." It doesn't say where the string is expected, so I'm stumped. Any ideas/thoughts?


回答1:


Can't test right now, but you might want to JSON.encode the sendData.

'If specified, sendData will send data in the form of a [ByteBuffer], [Blob], [Document], [String], or [FormData] along with the HttpRequest. '



来源:https://stackoverflow.com/questions/19777665/httprequest-request-with-senddata-cant-seem-to-get-this-to-work

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!