1.1.2 • Published 2 years ago

@as-watson-test/watson_sdk v1.1.2

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

As_Watson_SDK

Install

Create file .npmrc in your project and add token into this file.

Because this is private package, you must add token.

@evan117:registry=https://gitlab.com/api/v4/packages/npm/
//gitlab.com/api/v4/packages/npm/:_authToken=PEvzgszHyuG-ySDywWZ8

NPM install.

npm install @evan117/as_watson_sdk
npm install @as-watson-test/watson_sdk

Usage:React and React-Native

import React, {useState, useEffect} from 'react';
import API, {ProductListType} from '@as-watson-test/watson_sdk';

const App = () => {
  const [data$, setData$] = useState<ProductListType>([]);
  
  // Step1. Must use setBaseURL(<baseURL>) to initial.
  API.setBaseURL(<baseURL>);
  
  // Step2. Use getBaseURL() will return the set of baseURL.
  console.log(API.getBaseURL())
  
  // Step3. Use getProductList() method get Products data.
  // Notice the Lifecycle.
  useEffect(() => {
    API.getProductList()?.then((data: ProductListType) => {
      console.log(data);
      setData$(data);
    });
  }, []);
  
  

  return (
    <>
    </>
  );
};

Properties

PropTypeDescription
setBaseURLfunction(url:string)Use API.setBaseURL(<yourURL>) to setting baseURL.
getBaseURLreturn stringUse API.getBaseURL() will be return baseURL.
getProductListPromise<ProductListType>Use API.getProductList() to get ProductListData.

API Type

Type NameType
ProductTypecode: string;name: string;promotionFirstTag: string;imagesUrl: string;oldPrice: string;markDownPrice: string;averageRating: number; productNumberOfReview: number;stockLevelStatus: string;
ProductListTypeArray<ProductType>
ProductApiTypesetBaseURL:(url: string) => void;getBaseURL:getBaseURL: () => string;getProductList:() => Promise<ProductListType> or void;

Result

Angular
image
React
image