JSPM

  • Created
  • Published
  • Downloads 1832
  • Score
    100M100P100Q115459F
  • License MIT

A useful axios helper

Package Exports

  • @varlet/axle
  • @varlet/axle/es/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@varlet/axle) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

A tool library based on axios to simplify the development process

Quickstart

Install

# Install with npm, yarn or pnpm

# npm
npm i @varlet/axle -S

#yarn
yarn add @varlet/axle

#pnpm
pnpm add @varlet/axle

Request call

import { createAxle } from '@varlet/axle'

// create axle instance
const axle = createAxle(/** @see https://axios-http.com **/)

// The built-in axios of the axle, the usage is exactly the same as that of axios, and shares the configuration with the axle.
const { axios } = axle

const response = await axle.get('/user', { current: 1, pageSize: 10 }, { headers: {} })
const response = await axle.post('/user', { name: 'Axle' }, { headers: {} })

Vue Composition Api

<script setup>
import { createAxle, createUseAxle } from '@varlet/axle'

const axle = createAxle()
const useAxle = createUseAxle()

// default immediate request
const [users, getUsers, loading, { error }] = useAxle({
  runner: axle.get,
  url: '/user',
  params: { current: 1, pageSize: 10 },
  config: { headers: {} }
})
</script>

<template>
   <span>{{ users }}</span>
   <span>{{ loading }}</span>
   <span>{{ error }}</span>
</template>

Repo Status

WIP and Trying