Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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>
- import React, { Component } from 'react';
- import {
- Text,
- View,
- ScrollView
- } from 'react-native';
- import { List, ListItem } from 'react-native-elements';
- import OData from 'react-odata';
- const baseUrl = 'http://PRIVATE/odata/Products';
- // according to the code in odata.js we use false to send no options
- // I also tried using { filter: { ProductId: 1 } };
- // I also tried using { filter: { ProductId: '1' } };
- const query = false;
- class ProductList extends Component {
- onLearnMore = (user) => {
- this.props.navigation.navigate('Details', { ...user });
- };
- render() {
- return (
- <ScrollView>
- <OData baseUrl={baseUrl} query={query}>
- {({ loading, error, data }) => (
- <View style={{ height: 400 }}>
- <Text>HI THERE!!</Text>
- {loading && <Text>Loading...</Text>}
- {error && <Text>error...</Text>}
- {data &&
- <List>
- <ListItem
- key="1234"
- title="Sample Item" />
- <ListItem
- key="1235"
- title="Smaple Item 2" />
- {data.map((product) => (
- <ListItem
- key={product.ProductId}
- title={`${product.ItemCode}`}
- />
- ))}
- </List>
- }
- </View>
- )}
- </OData>
- </ScrollView>
- );
- }
- }
- export default Feed;
- componentWillMount() {
- alert('fetching');
- fetch(baseUrl)
- .then((response) => response.json())
- .then((responseJson) => {
- alert('returned ' + responseJson.value[0].ItemCode);
- return responseJson.value
- })
- .catch((error) => { console.error(error) });
- }
Add Comment
Please, Sign In to add comment