MCPcopy
hub / github.com/github/docs / getProductExampleData

Function getProductExampleData

middleware/contextualizers/product-examples.js:4–16  ·  view source on GitHub ↗
(product, key, language)

Source from the content-addressed store, hash-verified

2import { getDataByLanguage } from '../../lib/get-data.js'
3
4function getProductExampleData(product, key, language) {
5 // Because getDataByLanguage() depends on reading data files from
6 // disk, asking for something that doesn't exist would throw a
7 // `ENOENT` error from `fs.readFile` but we want that to default
8 // to `undefined` because certain product's don't have all product
9 // examples.
10 try {
11 return getDataByLanguage(`product-examples.${product}.${key}`, language)
12 } catch (error) {
13 if (error.code === 'ENOENT') return
14 throw error
15 }
16}
17
18export default async function productExamples(req, res, next) {
19 if (!req.context.page) return next()

Callers 1

productExamplesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected