Skip to content
Node: axios.create()github.com/sahilkhaire/gox/client

Client.New

Overview

New creates a Client with optional timeout.

If you are coming from Node.js, the closest pattern is axios.create().

Method on Client — call it on a value of that type after constructing or receiving one from a constructor.

Signature

go
func New() *Client

Compare: Node.js · Standard Go · gox

js
axios.create()
go
resp, err := http.NewRequestWithContext(ctx, method, url, body)
client.Do(req)
go
import "github.com/sahilkhaire/gox/client"

client.New()

Example

go
import "github.com/sahilkhaire/gox/client"

client.New()

Tips

Pass context.Context as the first argument so cancellation and deadlines propagate correctly.

Standard library alternative

Use the standard library directly:

go
resp, err := http.NewRequestWithContext(ctx, method, url, body)
client.Do(req)

Back to client package overview

MIT Licensed · Built for Node.js developers moving to Go