fetch

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2026 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fetch

type Fetch struct {
}

func (Fetch) Exports

func (f Fetch) Exports() map[string]any

func (Fetch) ExportsWithEngine

func (f Fetch) ExportsWithEngine(e *engine.Engine) map[string]any

func (Fetch) Identity

func (f Fetch) Identity() string

func (Fetch) TypeDefine

func (f Fetch) TypeDefine() []byte

type Option

type Option struct {
	Method         string
	Mode           string
	Cache          string
	Credentials    string
	Headers        map[string]string
	Redirect       string
	ReferrerPolicy string
	Body           goja.Value
}

func (*Option) Request

func (o *Option) Request(e *engine.Engine, jar *cookiejar.Jar, uri string) *goja.Promise

type Response

type Response struct {
	Status     int
	StatusText string
	Type       string
	Url        string
	Headers    map[string]string
	Ok         bool
	BodyUsed   bool
	// contains filtered or unexported fields
}

func (*Response) ArrayBuffer

func (r *Response) ArrayBuffer() *goja.Promise

func (*Response) Json

func (r *Response) Json() *goja.Promise
func (r *FetchResponse) Blob() *goja.Promise {
	p, ack, rj := r.engine.NewPromise()
	if r.BodyUsed {
		rj(http.ErrBodyReadAfterClose)
		return p
	}
	go func() {
		defer r.res.Body.Close()
		r.BodyUsed = true
		bin, err := io.ReadAll(r.res.Body)
		if err != nil {
			rj(err)
		}
		ack(r.engine.ToValue(r.engine.NewArrayBuffer(bin)))
	}()
	return p
}

func (*Response) Text

func (r *Response) Text() *goja.Promise

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL