Skip to content
This repository has been archived by the owner on Jul 14, 2019. It is now read-only.

Add new RequestInterceptor

Latest
Compare
Choose a tag to compare
@hideokamoto hideokamoto released this 01 Jul 10:36
· 1 commit to master since this release

The Alexa Blog says to cache the product data by using RequestInterceptor.
https://developer.amazon.com/ja/blogs/alexa/post/75ee61df-8365-44bb-b28f-e708000891ad/how-to-use-interceptors-to-simplify-handler-code-and-cache-product-and-purchase-information-in-monetized-alexa-skills

Today, we provides a new Interceptor to cache the data in your Skill.
You can cache the ISP Product data by the following code.

import { loadISPDataInterceptor } from '@ask-utils/isp'

// add interceptor
.addRequestInteceptor(loadISPDataInterceptor)

And you can get the products by the following code.

// get product from session attributes
import { getAllEntitledProducts } from '@ask-utils/isp'

const { inSkillProducts } = handlerInput.attributesManager.getSessionAttributes()
const entitledProducts = getAllEntitledProducts(inSkillProducts)