Package Exports
- northfork-sdk
- northfork-sdk/build/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (northfork-sdk) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Northfork Javascript SDK
SDK for accessing Northfork APIs avaliable for client-side (running in browser) as well as backend (running on node.js)
Code Example
import { initialize, getRecipe } from 'northfork-sdk'
//wait until initialization will finish
await initialize({ username: 'my-username', stage: 'development' })
//get recipe by id
const recipe = await getRecipe('recipe-id')
console.log('Got recipe', recipe.title)
API Reference:
Data Types:
- Recipe
- Ingredient
- InitResponse
initialize Props (returns Promise<InitResponse>)
Initialized an instance of sdk. No need to save InitResponse
, sdk will save and authorize user by itself after calling initialize
(see code examples above)
Name | Description | Type | Required | Default Value |
---|---|---|---|---|
username | Username used for authorization | string | Yes | - |
stage | Specify if test or prod environment should be used | "production" | "development" | No | "production" |
getRecipe Props (returns Promise<Recipe>)
Name | Description | Type | Required | Default Value |
---|---|---|---|---|
recipeId | RecipeId to search for | string | Yes | - |
Data Types
Recipe
Name | Description | Type |
---|---|---|
id | Unique Recipe id | string |
title | Name of the recipe | string |
portions | Number of serves (people to feed). By default 4. Range: 1 - 20. | number |
cookingTime | Cooking time in minutes | number |
imageUrl | Url to a recipe image | string |
ingredients | A list of ingredients | Ingredient[] |
published | If this recipe was published (accessible online) | boolean |
InitResponse
Name | Description | Type |
---|---|---|
accessToken | Token used to access API via HTTP Authorization header | string |
refreshToken | Token used to refresh accessToken | string |
type | Authorization type. Usually just 'Bearer' | string |