func (c Client) Do(dom DOM, req Request) (*Response, error) {
	if dom == nil {
		return nil, errors.New("DOM not specified")
	}
	xhr := dom.NewXHR()
	xhr.Call("open", req.Method, req.URL)
	timeoutMillis := c.Timeout.Milliseconds()
	xhr.Set("timeout", timeoutMillis)
	for k, v := range req.Headers {
		xhr.Call("setRequestHeader", k, v)
	}
	responseC := make(chan Response)
	eventHandler := dom.NewJsEventFunc(handleEvent(xhr, responseC))
	defer eventHandler.Release()
	xhrEventTypes := []string{"load", "timeout", "abort", "error"}
	for _, event := range xhrEventTypes {
		xhr.Call("addEventListener", event, eventHandler)
	}
	go xhr.Call("send", req.Body)
	response := <-responseC
	if response.err != nil {
		return nil, response.err
	}
	return &response, nil
}
// Do makes a HTTP request.
Do makes a HTTP request.
// Do makes a HTTP request .
func (c Client) Do(dom DOM, req Request) (*Response, error) {
	if dom == nil {
		return nil, errors.New("DOM not specified")
	}
	xhr := dom.NewXHR()
	xhr.Call("open", req.Method, req.URL)
	timeoutMillis := c.Timeout.Milliseconds()
	xhr.Set("timeout", timeoutMillis)
	for k, v := range req.Headers {
		xhr.Call("setRequestHeader", k, v)
	}
	responseC := make(chan Response)
	eventHandler := dom.NewJsEventFunc(handleEvent(xhr, responseC))
	defer eventHandler.Release()
	xhrEventTypes := []string{"load", "timeout", "abort", "error"}
	for _, event := range xhrEventTypes {
		xhr.Call("addEventListener", event, eventHandler)
	}
	go xhr.Call("send", req.Body)
	response := <-responseC
	if response.err != nil {
		return nil, response.err
	}
	return &response, nil
}
func ( c Client ) Do ( dom DOM , req Request ) ( * Response , error ) { if dom == nil { return nil , errors . New ( " " ) } xhr := dom . NewXHR ( ) xhr . Call ( " " , req . Method , req . URL ) timeoutMillis := c . Timeout . Milliseconds ( ) xhr . Set ( " " , timeoutMillis ) for k , v := range req . Headers { xhr . Call ( " " , k , v ) } responseC := make ( chan Response ) eventHandler := dom . NewJsEventFunc ( handleEvent ( xhr , responseC ) ) defer eventHandler . Release ( ) xhrEventTypes := [ ] string { " " , " " , " " , " " } for _ , event := range xhrEventTypes { xhr . Call ( " " , event , eventHandler ) } go xhr . Call ( " " , req . Body ) response := <- responseC if response . err != nil { return nil , response . err } return & response , nil }
Do makes a HTTP request.
Do makes a HTTP request .