0.0.38 • Published 2 years ago

salesbit-api-client-svelte v0.0.38

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

create-svelte

Everything you need to build a Svelte library, powered by create-svelte.

Read more about creating a library in the docs.

Creating a project

If you're seeing this, you've probably already done this step. Congrats!

# create a new project in the current directory
npm create svelte@latest

# create a new project in my-app
npm create svelte@latest my-app

Developing

Once you've created a project and installed dependencies with npm install (or pnpm install or yarn), start a development server:

npm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open

Everything inside src/lib is part of your library, everything inside src/routes can be used as a showcase or preview app.

Building

To build your library:

npm run package

To create a production version of your showcase app:

npm run build

You can preview the production build with npm run preview.

To deploy your app, you may need to install an adapter for your target environment.

Publishing

Go into the package.json and give your package the desired name through the "name" option. Also consider adding a "license" field and point it to a LICENSE file which you can create from a template (one popular option is the MIT license).

To publish your library to npm:

npm publish

Testing

npm install salesbit-api-client -w salesbit-api-client-svelte

Usage

Install packages

npm install salesbit-api-client --save
npm install salesbit-api-client-svelte --save

Quick start example

import { APIClient } from 'salesbit-api-client';
import Properties from '$lib/product/Properties.svelte';
import Price from '$lib/product/Price.svelte';
import Checkout from '$lib/Checkout.svelte';

let client: APIClient;
let product;
let loading = false;

onMount(async () => {
  client = new APIClient(
    'https://api.server.com',
    '11111111-...',
    'prj1-...'
  );
  try {
    loading = true;
    const resp = await client.getProduct('1-17');
    console.log(resp);
    product = resp;
  } catch (err) {
    console.error(err);
  } finally {
    loading = false;
  }
});

{#if product}
	<div>
		<Properties title="Properties" bind:product></Properties>
		<Price title="Price" bind:product></Price>
		<Checkout {client}></Checkout>
	</div>
{:else}
	<div>loading</div>
{/if}
0.0.37

2 years ago

0.0.38

2 years ago

0.0.35

2 years ago

0.0.36

2 years ago

0.0.20

2 years ago

0.0.21

2 years ago

0.0.22

2 years ago

0.0.23

2 years ago

0.0.24

2 years ago

0.0.25

2 years ago

0.0.15

2 years ago

0.0.16

2 years ago

0.0.17

2 years ago

0.0.18

2 years ago

0.0.19

2 years ago

0.0.30

2 years ago

0.0.31

2 years ago

0.0.32

2 years ago

0.0.33

2 years ago

0.0.34

2 years ago

0.0.13

2 years ago

0.0.14

2 years ago

0.0.26

2 years ago

0.0.27

2 years ago

0.0.28

2 years ago

0.0.29

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago