Image

February 25, 2021 ยท View on GitHub

The Image class will grab the image for a product code and base 64 encode it. It extends the js-base64-file class.

Pizza image

If you have cloned this repo, you can run the example with this command: node ./example/image.js

Constructor

new Image('S_PIZPX')
paramstyperequireddescription
productCodestringyesproduct code from the menu

Instance

This extends the js-base64-file class. See its documentation for the inherited class members and methods.

member/methodtypedescription
base64Imagestringbase64 encoded dominos image

import {Image} from 'dominos';

const productCode='S_PIZPX';
const savePath='./';

const pepperoniPizza=await new Image(productCode);
console.log(pepperoniPizza.base64Image);

//you could pass this to a user via sms, web socket, http, tcp, make an ascii art for the terminal, OR save it to disk or a database
//here we just save it to disk as an example.
//this is part of the js-base64-file class refrence, there is a link at the top of this file
pepperoniPizza.saveSync(pepperoniPizza.base64Image,savePath,productCode+'.jpg');