8000 [proposal] xhr.Send() provides some opts to set the xhr header · Issue #7 · dominikh/go-js-xhr · GitHub
[go: up one dir, main page]

Skip to content
7FFF

[proposal] xhr.Send() provides some opts to set the xhr header #7

Open

Description

@scbizu

Hi , issue and PR will be accepted here ?

I think I need some options to do with the xhr.Send() rather than create a new func to send request with different headers .

Maybe something like this ?

type XHRRequestOption func(*Request)*Request{}

func Send(method, url string, data []byte, opts ...XHRRequestOption) ([]byte, error) {
	xhr := NewRequest(method, url)
	xhr.ResponseType = ArrayBuffer
        for _,opt:=range opts {
            xhr = opt(xhr)
       }
	err := xhr.Send(data)
	if err != nil {
		return nil, err
	}
	return js.Global.Get("Uint8Array").New(xhr.Response).Interface().([]byte), nil
}

I can raise a pr if it is possible .

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0