1.9.1 • Published 3 years ago

@chief-noob/restaurant-ts-sdk v1.9.1

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

Restaurant API SDK for Typescript

Introduction

點菜通系統 API 串接套件,用於 Typescript 前端開發。

Usage

Create a useAPI hook in project, inject the API_URL and session.

// hooks/useAPI.ts

import useSession from './useSession';
import API_URL from '../config';
import useRestaurantAPI from '@chief-noob/restaurant-ts-sdk';

function useAPI() {
  const session = useSession();
  return useRestaurantAPI(API_URL, session);
}

export default useAPI;

In component, simply use this hook to access the API service.

function RestaurantScreen() {
  const API = useAPI();
  const [restaurant, setRestaurant] = useState<Restaurant>();
  
  useEffect(() => {
    refresh();
  }, []);

  async function refresh() {
      const l = await API.restaurant.getOne(restaurantID);
      setRestaurant(l);
  }
  
  return (
    <View>
    ...
    </View>
  );
}
1.9.1

3 years ago

1.9.0

3 years ago

1.8.12

3 years ago

1.8.13

3 years ago

1.8.14

3 years ago

1.8.15

3 years ago

1.8.11

3 years ago

1.8.9

3 years ago

1.8.10

3 years ago

1.8.8

3 years ago

1.8.7

3 years ago

1.8.6

3 years ago

1.8.5

3 years ago

1.8.4

3 years ago

1.8.3

3 years ago

1.8.2

3 years ago

1.8.1

3 years ago

1.8.0

3 years ago

1.7.9

3 years ago

1.7.8

3 years ago

1.7.7

3 years ago

1.6.4

3 years ago

1.7.2

3 years ago

1.6.3

3 years ago

1.7.1

3 years ago

1.6.2

3 years ago

1.7.0

3 years ago

1.6.1

3 years ago

1.6.0

3 years ago

1.7.36

3 years ago

1.6.9

3 years ago

1.6.8

3 years ago

1.7.6

3 years ago

1.6.7

3 years ago

1.7.5

3 years ago

1.6.6

3 years ago

1.7.4

3 years ago

1.6.5

3 years ago

1.5.9

3 years ago

1.5.8

3 years ago

1.5.7

3 years ago

1.5.5

3 years ago

1.5.4

3 years ago

1.5.3

3 years ago

1.5.2

3 years ago

1.5.1

3 years ago

1.5.0

3 years ago

1.4.9

3 years ago