· 5 years ago · May 05, 2020, 04:16 PM
1const openLDBWS = require('ldbws-json');
2const operation = require('ldbws-json/LDBWSOperation');
3const requestData = require('ldbws-json/LDBWSRequestData');
4const operationInfo = require('ldbws-json/LDBWSOperationInfo');
5
6// Put a valid Token here
7const token = "NETWORK_RAIL_ACCESS_CODE_HERE";
8
9// Select the operation method we will call and use the helper to extract the result
10// use of resultkeys is optional and provided for convienience only
11const method = operation.GET_DEPARTURE_BOARD_WITH_DETAILS;
12const key = operationInfo[method].key;
13
14// populate the required data structure here we use the CRS code for London Victoria
15const options = Object.assign({}, requestData.Board);
16options.crs = "STP";
17
18// call the API, wait then return the result
19const api = new openLDBWS(token);
20api.call(operation.GET_DEPARTURE_BOARD_WITH_DETAILS, options).then((board)=>{
21
22 console.log(JSON.stringify(board[key], undefined, 2));
23
24});