Get page by URL
Fetches a single page by its URL identifier.
What this example does:
- Connects to the OneEntry API
- Retrieves a page by its URL identifier
- Accesses page content via localizeInfos and attributeValues
Prerequisites:
- A valid PROJECT_URL and APP_TOKEN for the OneEntry API.
- A page configured in OneEntry with a known URL (e.g., "home_web")
Notes:
- By default (
isShell: true) the SDK returns an error object instead of throwing, so check the result, e.g.'statusCode' in result. WithisShell: falseit throws, and you handle errors with try/catch. See Errors.
Platform docs:
SDK reference:
Try it live
Run this example in the JS SDK sandbox. Connect your Project URL and App Token on first visit, then open:
Scenario
1. Import defineOneEntry and define PROJECT_URL and APP_TOKEN
import { defineOneEntry } from 'oneentry';
const PROJECT_URL = 'https://your-project.oneentry.cloud';
const APP_TOKEN = 'your-app-token';
2. Create an API client with defineOneEntry()
const { Pages } = defineOneEntry(PROJECT_URL, {
token: APP_TOKEN,
});
3. Get page by URL with Pages.getPageByUrl()
const page = await Pages.getPageByUrl('home_web');
if ('statusCode' in page) {
throw new Error(page.message);
}
console.log(page.localizeInfos.title, page.attributeValues);
Result:
{
"id": 9,
"parentId": null,
"pageUrl": "home_web",
"depth": 0,
"localizeInfos": {
"title": "Home web",
"menuTitle": "Home web",
"htmlContent": "",
"plainContent": ""
},
"isVisible": true,
"blocks": [],
"type": "common_page",
"templateIdentifier": null,
"attributeSetIdentifier": null,
"attributeValues": {},
"moduleFormConfigs": [],
"isSync": false
}
Final example
// 1. Import defineOneEntry and define PROJECT_URL and APP_TOKEN
import { defineOneEntry } from 'oneentry';
const PROJECT_URL = 'https://your-project.oneentry.cloud';
const APP_TOKEN = 'your-app-token';
// 2. Create an API client with defineOneEntry()
const { Pages } = defineOneEntry(PROJECT_URL, {
token: APP_TOKEN,
});
// 3. Get page by URL with Pages.getPageByUrl()
const page = await Pages.getPageByUrl('home_web');
if ('statusCode' in page) {
throw new Error(page.message);
}
console.log(page.localizeInfos.title, page.attributeValues);