npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@aluni/plugin-request

v0.0.5

Published

@aluni/plugin-request

Readme

@aluni/plugin-request

See our website inula for more information.

Inula-request openinula 提供的一个请求库。

配置

在运行时配置中,配置的将是全局的默认配置,如下配置,会给所有的请求增加前缀 url 和 headers。

import { IrRequestConfig } from 'inula';

export const request: IrRequestConfig = {
  baseURL: '/api',
  headers: {
    inula: 'haha',
  },
};

使用方式

提供 ir 对象,可以使用 ir.getir.postir.deleteir.put等方法,详见 Inula-request 全局 API

请注意从全局引出的对象,都将使用上诉配置中配置的默认值,如果在你的项目中需要两个不同的请求实例,你可以使用 ir.create 来创建一个新的实体对象。

请注意以下为用法示例,并非是唯一用法

创建一个 services 将接口 api 地址转化成变量在组件中使用,很像我们将长字符串写成一个静态常量的开发习惯。

import { ir } from 'inula';

export async function sayHi(params: Record<string, any>): Promise<any> {
  return ir.get('/hello', {
    params,
  });
}

在页面中使用

import { sayHi } from '@/services/api';
import { useState } from 'inula';

const Page = () => {
  const [title, setTitle] = useState();
  return (
    <div
      onClick={async () => {
        const { data } = await sayHi({});
        setTitle(data?.text);
      }}
    >
      inula-request {title}
    </div>
  );
};

export default Page;

也可以与 ahooks 一起使用,开发时会更加的便利,无需反复的 setData

内置了 useRequest 来自 ahooks 吧,如果你需要特定版本的 ahooks ,你只需要在项目中安装特定版本,框架会自动变更引用。

import { sayHi } from '@/services/api';
import { useRequest } from 'inula';

const Page = () => {
  const { data, error } = useRequest(sayHi,{});
  console.log(data)
  console.log(error)
  return (
    <div>
      inula-request {data.title}
    </div>
  );
};

export default Page;

对于一些需要动态轮询的实时数据刷新能力的接口,可以使用 useIR hook 来完成,详见 请求实时刷新 API

import { useIR, } from 'inula';

const Page = () => {
  const { data, error } = useIR('/hello');
  console.log(data)
  console.log(error)
  return (
    <div>
      inula-request {data.title}
    </div>
  );
};

export default Page;

TODO

根据接口文档地址,生成 services 文件。(等 openinula 官方实践完成,再实现此功能)