Skip to content

Commit

Permalink
Use Heroku server for API calls
Browse files Browse the repository at this point in the history
  • Loading branch information
ML-Chen committed Apr 29, 2020
1 parent 539cd8d commit 504ac00
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion frontend/src/pages/Discover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function fetcher(url: string) {
}

const Discover: React.FC<RouteComponentProps> = () => {
const { data, error } = useSWR('http://localhost:3001/api/listings/nearby', fetcher);
const { data, error } = useSWR('https://storestash.herokuapp.com/api/listings/nearby', fetcher);
let content;
if (error)
content = <div>failed to load</div>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/Listing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const Listing: React.FC<RouteComponentProps & {listingId: string}> = (props) =>
e.preventDefault();
if (validate()) {
try {
await wretch(`http://localhost:3001/api/listings/${listingId}/rent`)
await wretch(`https://storestash.herokuapp.com/api/listings/${listingId}/rent`)
.post({
renter: userId,
boxes,
Expand All @@ -75,7 +75,7 @@ const Listing: React.FC<RouteComponentProps & {listingId: string}> = (props) =>
}
}

const { data, error } = useSWR(`http://localhost:3001/api/listings/${listingId}`, url => wretch(url).get().json());
const { data, error } = useSWR(`https://storestash.herokuapp.com/api/listings/${listingId}`, url => wretch(url).get().json());
let listing;
if (!listingId || error)
listing = <div>Failed to load</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const Login: React.SFC<RouteComponentProps> = (props) => {
}
try {
// TODO: get authorization token
await wretch('http://localhost:3001/api/login')
await wretch('https://storestash.herokuapp.com/api/login')
.post({ email, password })
.json(data => {
console.log(data);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default class Post extends React.Component<any, any> {
console.log(typeof price);
console.log(typeof capacity);
console.log(typeof today);
await wretch('http://localhost:3001/api/listings/new')
await wretch('https://storestash.herokuapp.com/api/listings/new')
.post({ id, hostId, lat, lon, capacity, startDate: new Date(this.state.startDate), endDate: new Date(this.state.endDate), price, image: this.state.imageUrl })
.json(data => console.log(data));
this.props.history.push('/listing_confirmation')
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/pages/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ const Profile: React.FC<RouteComponentProps> = (props) => {

// TODO: re-fetch on page load

const { data: listings, error: errorListings } = useSWR(userId ? `http://localhost:3001/api/users/${userId}/listings` : null, url => wretch(url).get().json());
const { data: lendings, error: errorLendings } = useSWR(userId ? `http://localhost:3001/api/users/${userId}/lendings` : null, url => wretch(url).get().json());
const { data: rentals, error: errorRentals } = useSWR(userId ? `http://localhost:3001/api/users/${userId}/rentals` : null, url => wretch(url).get().json());
const { data: listings, error: errorListings } = useSWR(userId ? `https://storestash.herokuapp.com/api/users/${userId}/listings` : null, url => wretch(url).get().json());
const { data: lendings, error: errorLendings } = useSWR(userId ? `https://storestash.herokuapp.com/api/users/${userId}/lendings` : null, url => wretch(url).get().json());
const { data: rentals, error: errorRentals } = useSWR(userId ? `https://storestash.herokuapp.com/api/users/${userId}/rentals` : null, url => wretch(url).get().json());
if (!errorListings && listings) {
listingsContent = listings.length > 0 ? listings.map(listing => <YourListingCard {...listing} key={listing._id} />) : <IonItem><IonLabel>No listings (yet!)</IonLabel></IonItem>
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const Register: React.FC<RouteComponentProps> = (props) => {
// TODO: get authorization token
if (!validationErr) {
try {
await wretch('http://localhost:3001/api/users/new')
await wretch('https://storestash.herokuapp.com/api/users/new')
.post({
email,
password: password1,
Expand Down

0 comments on commit 504ac00

Please sign in to comment.