Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow a custom fetch function to be provided in props #14

Merged

Conversation

tuukka
Copy link
Contributor

@tuukka tuukka commented Apr 26, 2023

I considered how to best customize the API requests and figured that allowing a custom fetch function would be the most flexible and clean way.

If this new prop isn't present, the library will continue to function as before.

For example, it becomes easy to modify the URL parameters:

  <ReactAutosuggestGeocoder
    fetch={(resource, options) => {
      return fetch(resource + "&key=value", options);
    }
    // ...
  />

@generalpiston
Copy link
Owner

@tuukka this is supposed to be integrated with pelias. Did you want to integrate this with something else?

@tuukka
Copy link
Contributor Author

tuukka commented Apr 27, 2023

Hi @generalpiston! Yes and no: I have to send the requests to a Pelias instance which is behind a cloud API gateway that looks for the API key under a different parameter name. Also, I want to rewrite the autocomplete requests to go to the search endpoint as it works better in my use case.

Going forward, more tweaks may be needed especially as I don't control the instance.

Copy link
Owner

@generalpiston generalpiston left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Thanks!

@generalpiston generalpiston merged commit a884fab into generalpiston:master Apr 27, 2023
@generalpiston
Copy link
Owner

@tuukka I'll see if I can do a release soon for this project.

@tuukka
Copy link
Contributor Author

tuukka commented Apr 28, 2023

@generalpiston Thank you! I opened another pull request with some housekeeping in case it can help when making a release: #15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants