New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@pendant/api-react

Package Overview
Dependencies
Maintainers
4
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pendant/api-react

> TODO: description

latest
npmnpm
Version
0.0.6
Version published
Maintainers
4
Created
Source

api-react

快速请求 CODING OPEN API

Usage

import { setConfig, useFetchApi } from '@pendant/api-react';

setConfig({ clientId: '1234565' });

const ProjectListDemo = () => {
  const { response, error } = useFetchApi('DescribeCodingProjects', query);

  if (error || response?.Error) {
    return <>获取数据错误</>
  }

  if (response?.Data?.ProjectList instanceof Array) {
    return response?.Data?.ProjectList.map(project => <div>{project.Name}<div>)
  }

  return <>loading</>;
}

export default ProjectListDemo;

Api

setConfig

设置 api-react 的配置

{
  clientId: string;
  fetch?: Parameters<typeof fetch>;
}
参数说明类型默认值
clientId客户端 IDstring-
fetchfetch 的默认参数[RequestInfo | URL, { headers: RequestInit['headers'] }],在发送请求的时候会合并到 参数里面。Parameters-

fetchApi

函数式使用 fetchApihooks 使用 useFetchApi .

fetchApi('DescribeCodingProjects', query).then((res) => console.log(res));
const { response, error } = useFetchApi('DescribeCodingProjects', query);
参数说明类型默认值
action需要调用的业务 idstring-
query请求参数Object-

getContext

获取应用的上下文信息

const { accessToken, apiUrl } = await getContext();

FAQs

Package last updated on 19 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts