1.0.11 • Published 1 year ago

@momsfriendlydevco/faxios v1.0.11

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@MomsFriendlyDevCo/Faxios

Tiny utility wrapper to add Axios functionality to Fetch.

  • Automatic JSON decoding - No more silly 'await request.json()` calls
  • Single object requests - Throw around single AxiosRequest objects instead of the URL + config (except the URL query bits of course) stuff that Fetch insists you do
  • Less foot-guns - URL query strings are automatically handled by the params options structure
  • Multipart data encoding - Simply pass {dataType: 'formData'} to wrap all data inside new FormData() structures instead of standard JSON encoding
  • Simple default injection - As with Axios, its simple to extend the defaults object to include common headers or data entities that should always be used
  • Error detection + warning (dev mode only) - Faxios will yell at you nicely if you try to use a feature that you should probably use a full library for like parameter serialization, proxies or agent overrides
  • Intercept / tap into pre-fetch callbacks - See the value of the final Fetch URL + FetchConfig while logging - see onConfig()
  • Fully compatible with Cloudflare workers - ... and all its weird not-quite-JavaScript runtime API
import faxios from '@momsfriendlydevco/faxios';

// Simple posting
let {data} = await faxios.post('https://somewebsite.com/api/something', {
    foo: 1,
    bar: 2,
    baz: 3,
})


// Single object AxiosRequest parity
let {data} = await faxios({
    method: 'PUT',
    url: 'https://somewebsite.com/api/something',
    auth: { // Handle Base64 basic auth natively
        username: 'api',
        password: 'mega-secure-api-token',
    },
    dataType: 'formData', // Encode data with `new FormData()` rather than `JSON.stringify()`
    data: {
        foo: 1,
        bar: 2,
        baz: 3,
    },
})
1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago