fetch

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package fetch provides the fetch() API for transpiled TypeScript code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RequestInit

type RequestInit struct {
	Method  string
	Headers map[string]string
	Body    string
}

RequestInit holds options for a fetch request.

type Response

type Response struct {
	Status     int
	StatusText string
	Ok         bool
	Headers    http.Header
	// contains filtered or unexported fields
}

Response wraps an HTTP response with JS-like methods.

func Fetch

func Fetch(url string, opts ...RequestInit) (*Response, error)

Fetch performs an HTTP request (like globalThis.fetch).

func (*Response) Bytes

func (r *Response) Bytes() []byte

Bytes returns the response body as bytes.

func (*Response) JSON

func (r *Response) JSON(target any) error

JSON parses the response body as JSON into the target.

func (*Response) JSONValue

func (r *Response) JSONValue() (any, error)

JSONValue parses the response body as JSON and returns it.

func (*Response) Text

func (r *Response) Text() (string, error)

Text returns the response body as a string.

Jump to

Keyboard shortcuts

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