NPM package
First you will need to install our NPM package.
Simply run the command:
npm install edit-ease --saveEnviroment setup
To make successfull requests you will have to add a EE_API_KEY variable to your .env file.
Example
EE_API_KEY=<YOUR_PAGE_API_KEY>Note
You can only use one API key in a single website. This means that you can only fetch texts from one EditEase page.
Fetching texts
To fetch the texts simply import the getEditEaseText() function from the package. The function takes one string argument that corresponds to your text name.
getEditEaseText(label: string) : Promise<string>Async function
Since the function has to fetch the text value through the API, it is an async function. This should be taken into account when calling the function.
The function will return one of the following strings:
<TEXT_VALUE>- Successfully retrieved text valueEditEase text for '<TEXT_NAME>' not found- The text with name <LABEL> could not be found on the pageWrong EditEase API key- If the key was found but it is not correct (no page has such key)Unauthorized API call- If there is no API keyUnsuccessfull API cal- If the request has bad parameters
Example
Lets say we have a page with API key
my-api-keyand a text with namemy-textand valueLorem ipsum dolor sit amet.We have a
.envfile withEE_API_KEY=my-api-keyand a
test.jsWhen calling the
testEditEase()function the value of the text with namemy-textwill be printed to the console. MeaningLorem ipsum dolor sit ametwill be printed out to the console.
