Skip to main content

deno commercetools api 🦕

A small helper for using commercetools in combination with the deno runtime

How to get started

Install the Deno runtime on your machine, following this guidance: https://deno.land/

Prerequisites

A .env file in the root that contains the following:

CTP_PROJECT_KEY=******
CTP_CLIENT_SECRET=************
CTP_CLIENT_ID=****************
CTP_AUTH_URL=https://auth.europe-west1.gcp.commercetools.com
CTP_API_URL=https://api.europe-west1.gcp.commercetools.com
CTP_SCOPES=manage_project:ns-stations-demo

install the language server client for Deno in vscode, to make sure that vscode understands your code is for Deno and not for Node.

using the api

import {sdk, Project} from "https://deno.land/x/commercetools/api.ts";

async function project(handle: sdk): Promise<Project>
{
   const result = await handle
      .apiRoot()
      .withProjectKey( { projectKey: handle.projectKey })
      .get({})
      .execute()
   return result.body
}
const handle = sdk.init()
const pr = await project(handle)
console.log(pr)

run this example with:

deno run -A test.ts