Skip to content

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

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 .

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