lesscms
v1.2.4
Published
### Example ```ts // Create a project config const project = new Project("http://localhost:3000/", { project: "fcg1tvtmgfhE7XnMHzEZ", publicToken: "503de08d-558f-4720-830e-293ce2131cd9", })
Downloads
32
Readme
A library to interact with the the less cms system
Example
// Create a project config
const project = new Project("http://localhost:3000/", {
project: "fcg1tvtmgfhE7XnMHzEZ",
publicToken: "503de08d-558f-4720-830e-293ce2131cd9",
})
const regions = await project.getRegions({
countries: ["NO"]
// languages: [NB]
})
// Gets all the regions with countries: NO
console.log(regions)
const products = project.getCollection("myProductCollection")
// Get all items
const sampleProducts = await products.getItems()
// Get only a single items if configured in the project schema
const sampleProductSingle = await products.getSingle()
// Return error if no items
if (!sampleProducts) throw new Error("No products")
for (const product of sampleProducts) {
// Get prop in item
const cost = await product.getContent("cost")
// Console log content
console.log(cost)
}