reduncan / yelpclone

This is a project for a Coding Bootcamp. We are not profiting from this project.
https://yelpper.herokuapp.com/
3 stars 5 forks source link

Refactor Geocode function in results.js into classes #132

Open justinkook opened 5 years ago

justinkook commented 5 years ago

Geocode function inside results.js needs to be refactored into classes with constructors for each unique location input as properties.

Oluwasetemi commented 5 years ago
class Geocode {
  constructor(locationIndexInput) {
    this.location = locationIndexInput;
    // how do i handle the queryURL
  }
   const queryURL = (location) => 'api/geocode/' + location;
   $.get( `api/geocode/${this.location}`)
      .then(function (data) {
        let formattedAddress = data.results[0].formatted_address;
        let addressComponents = data.results[0].address_components;
        callAddressCityIndex(addressComponents[0].short_name, formattedAddress)
      })
      .catch(function (err) {
        console.log(err);
      })

}

Are you okay with the class like this?

justinkook commented 5 years ago

Yes! That looks correctly formatted / syntax. I can assign the issue to you if you are willing.

Oluwasetemi commented 5 years ago

Assign it to me!! I will send in the PR in some hours.

Oluwasetemi commented 5 years ago

I will need to initialize the class everywhere geocode() will be called.

justinkook commented 5 years ago

Sure, this issue has been assigned to @Oluwasetemi