EndpointRequestDefinition
Summary
EndpointRequestDefinition can send the request with defined parameters to the endpoint.
It also provides access to the parameters in the following way.
Methods
getData(session: Session)
Parameters:
Property | Is Optional | Default Value | Type | Description |
---|---|---|---|---|
session | No | - | Session | The Session defines the source where you want to retrieve your data |
Returned value: Promise<EndpointResponse<T>>
EndpointResponse
Property | Description |
---|---|
data | Defines data returned by the endpoint |
httpStatus | Defines HTTP status code from the endpoint response |
httpHeaders | Defines the headers that the endpoint responded with |
isSuccess | Defines if the response is successful or not |
Example of usage
session
.open()
.then(() => {
const historicalPricingRequestParams: EndpointRequestDefinitionParams = {
url: 'data/historical-pricing/v1/views/events/{universe}',
path: { universe: 'IBM' },
};
const historicalPricingEventsRequestDefinition = EndpointRequest.Definition(historicalPricingRequestParams);
return historicalPricingEventsRequestDefinition.getData(session);
})
.then(data => /*handle received data*/)
.catch(err => /*handle error*/)
.then(() => session.close());
const historicalPricingRequestParams: EndpointRequestDefinitionParams = {
url: 'data/historical-pricing/v1/views/events/{universe}',
path: { universe: 'IBM' },
};
const historicalPricingEventsRequestDefinition = EndpointRequest.Definition(historicalPricingRequestParams);
console.log(historicalPricingEventsRequestDefinition.url);
console.log(historicalPricingEventsRequestDefinition.path);