Internal
Creates a new RequestBuilderImpl
The entity to make the request for
new ODataRequest('Fractie')
Optional
_countWhether to count the amount of results
Optional
_expandThe attributes to select
Optional
_filterThe attributes to filter by
Optional
_formatThe format to return the results in
Optional
_orderbyThe order to sort the results by
The attributes to select
Optional
_skipAmount of results to skip
Optional
_topAmount of results to return
Optional
_customCustom query option
Endpoint to make the request to
"https://gegevensmagazijn.tweedekamer.nl/OData/v4/2.0"
Entity to make the request for
Optional
_idUnique id of the entity
Experimental
Overwrite the default endpoint
The endpoint to use
The RequestBuilderImpl
new ODataRequest('Fractie')
.endpoint('https://proxy.tweedekamer.nl/OData/v4/2.0')
Count the amount of results
Whether to count the amount of results
The RequestBuilderImpl
new ODataRequest('Fractie')
.count(true)
new ODataRequest('Fractie')
.count(false)
Expand the request to include information from other entities
The attribute to expand
Optional
func: stringThe function to apply to the attribute
The RequestBuilderImpl
new ODataRequest('Fractie')
.expand('FractieZetel')
.expand('Stemming', '$select=Soort')
new ODataRequest('Fractie')
.expand('FractieZetel')
// Multiple functions can be applied to the same expansion
// Using a semicolon (;) to separate them
.expand('Stemming', "$top=1 ; $select=Soort")
Filter the results
The expression to format the results with
The RequestBuilderImpl
new ODataRequest('Fractie')
.filter("Afkorting eq 'VVD'")
new ODataRequest('Fractie')
.filter("AantalZetels gt 10")
.filter("AantalZetels lt 20")
The amount of metadata to return with the results
The format to use
The RequestBuilderImpl
new ODataRequest('Fractie')
.format('none')
new ODataRequest('Fractie')
.format('minimal')
new ODataRequest('Fractie')
.format('full')
Order the results by a specific attribute
The attribute to order by
The direction to order by (asc or desc)
The RequestBuilderImpl
new ODataRequest('Fractie')
.orderby('NaamNL') // Direction defaults to asc
new ODataRequest('Fractie')
.orderby('NaamNL', 'asc')
new ODataRequest('Fractie')
.orderby('NaamNL', 'desc')
Select a specific attribute to return Will only show the attribute(s) selected for the entity
The attribute to select
The RequestBuilderImpl
new ODataRequest('Fractie')
// You can select multiple attributes
.select('NaamNL')
.select('NaamEN')
new ODataRequest('Fractie')
.select('NaamNL')
Skip the first n results
The amount of results to skip (1..n)
The RequestBuilderImpl
new ODataRequest('Fractie')
.skip(1)
new ODataRequest('Fractie')
.skip(250)
Limit the amount of results returned
The amount of results to return (1..250)
The RequestBuilderImpl
new ODataRequest('Fractie')
.top(1)
new ODataRequest('Fractie')
.top(250)
Error if $Top is already defined
Error if $Top is less than or equal to 0
Error if $Top is greater than 250
Use a custom query. Will overwrite all previously declared functions. And will directly use the given query. Functions declared after this function will also be ignored.
The custom query to use
The RequestBuilderImpl
Error if the query does not start with a '$'
new ODataRequest('Fractie')
.custom('$select=Afkorting')
// https://gegevensmagazijn.tweedekamer.nl/OData/v4/2.0/Fractie?$select=Afkorting
new ODataRequest('Fractie')
.custom('$select=Afkorting&$top=1')
// https://gegevensmagazijn.tweedekamer.nl/OData/v4/2.0/Fractie?$select=Afkorting&$top=1
Select multiple attributes to return Will only show the attribute(s) selected for the entity
The attributes to select
The RequestBuilderImpl
new ODataRequest('Fractie')
.selectMultiple(['NaamNL', 'NaamEN'])
// You can also use the select function multiple times
.selectMultiple(['DatumActief', 'DatumInactief'])
new ODataRequest('Fractie')
.selectMultiple(['NaamNL', 'NaamEN'])
// You can also use the selectMultiple function in combination with the select function
.select('DatumActief')
Select a list of attributes to return Will overwrite any previous select functions
The attributes to select
The RequestBuilderImpl
new ODataRequest('Fractie')
.setSelect(['NaamNL', 'NaamEN'])
Given the current state of the RequestBuilderImpl, build the request url according to functions provided
The build request url
const construction = new ODataRequest('Fractie')
.expand('FractieZetel')
.top(1)
// Log the request url (build)
console.log(construction.build());
Given the current state of the RequestBuilderImpl, build the request url according to functions provided and then utilize cross-fetch to make the request
The response from the request
cross-fetch - Fetch API implementation
Function flow: request -> build -> fetch
new ODataRequest('Fractie')
.expand('FractieZetel')
.expand('Stemming', '$select=Soort')
.top(1)
.request()
// Log the data
.then(data => console.log(data))
.catch(err => console.warn(err))
const construction = new ODataRequest('Fractie')
.expand('FractieZetel')
.expand('Stemming', '$select=Soort')
.top(1)
construction.request().then((data) => {
// Log the data
console.log(data);
}).catch((error) => {
console.warn(error);
});
Experimental
Unique function to gather information on a specific entity instead of the entire collection
The unique id of the entity
The RequestBuilderImpl
If invalid query options are provided
[!] Does not work with all other functions Query options $filter, $orderby, $count, $skip, and $top can be applied only on collections.
new ODataRequest('Fractie')
.findById('65129918-f256-4975-9da4-488da34d6695')
Generated using TypeDoc
RequestBuilderImpl
Description
Default implementation of the RequestBuilder interface
See
RequestBuilder - RequestBuilderImpl interface