0.0.2 • Published 2 years ago

@whalecloud/dx-fr-api v0.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

1. Setup

Let's install the packages we need:

npm install @whalecloud/dx-fr-api

2. learn GraphQLClient

@whalecloud/dx-fr-api use @fishx/graphql-client

@fishx/graphql-client

3. Initialize GraphQLClient

import React from 'react';
import { render } from 'react-dom';
import {
  useDxGraphQLClient,
  DxApiConatiner
} from "@whalecloud/dx-fr-api";
import { GraphQLClient } from '@fishx/graphql-client';
import axios from 'axios';

export const defRequest = axios.create({
  timeout: 10000,
  baseURL: '/portal/api',
  headers: {
    'X-Requested-With': 'XMLHttpRequest',
  },
});

export const defClient = new GraphQLClient('/portal/api/graphql', {
  headers: {
    'X-Requested-With': 'XMLHttpRequest',
  },
});




function App() {
  // 使用
  // const client = useDxGraphQLClient();
  return (
    <div>
      <h2>My first GraphQL app 🚀</h2>
    </div>
  );
}

render(
  <DxApiConatiner client={client}>
    <App />
  </DxApiConatiner>,
  document.getElementById('root'),
);