# Api

## Configure services

You can use `mockServer` from `geta-checkout` to test using dummy data.

```javascript
import { mockServer, CartApi } from 'geta-checkout';
const cartApi = new CartApi(mockServer.cartServices);
```

You may find the boilerplate below useful when implementing the service layer.
<br>
The exact implementation will depend on your project.
<br>
*Service-layer* in this context is just a fancy word for functions that send ajax-requests, receive json-responses and return promises.

<p style="min-height: 2500px"
data-height="2500"
data-theme-id="light"
data-slug-hash="ZeqwgM"
data-preview="false"
data-default-tab="js"
data-user="Geta"
data-embed-version="2"
data-pen-title="Example"
class="codepen">
</p>

## Add a custom API

If the built-in APIs don't cover your needs, you may want to build your own API.
<br>
You can copy and modify one of the built-in APIs, or use the simple boilerplate / pattern below.

Note that the example below has only one dependency to Geta Checkout; the `render` method.
<br>
The API code itself is just plain JavaScript.

This may look like a lot of code to display a random number.
<br>
However, as the complexity of the project grows, the pattern below will start to make a lot more sense.

<p style="min-height: 1600px"
data-height="1600"
data-theme-id="light"
data-slug-hash="xqyyga"
data-preview="false"
data-default-tab="js,result"
data-user="Geta"
data-embed-version="2"
data-pen-title="Example"
class="codepen">
</p>

<script async src="https://production-assets.codepen.io/assets/embed/ei.js"></script>