React component to declaratively fetch from OData v4 endpoints
yarn add react-odata
or
npm install --save react-odata
import OData from 'react-odata';
const baseUrl = 'http://services.odata.org/V4/TripPinService/People';
const query = { filter: { FirstName: 'Russell' } };
<OData baseUrl={baseUrl} query={query}>
{ ({ loading, error, data }) => (
<div>
{ loading && {/* handle loading here */} }
{ error && {/* handle error here */} }
{ data && {/* handle data here */}}
</div>
)}
</OData>
- See odata-query for supported
query
syntax
<OData baseUrl="http://services.odata.org/V4/TripPinService/People" options={{ credentials: 'include' }} />
- See react-fetch-component for additional props