-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
How can I use multiple APIs ? #851
Comments
That's not correct. in |
Here's the code I'm referring to (some stuff removed for clarity):
In your config you could just as easily have apiHost2 and apiPort2 or whatever you want to call it and then your coude would become the follwing:
|
hi All i have a http call in the widgetReducer its like function fetchData(getState, dispatch) { @Connectdata(fetchData, null) |
While that is true, it's not as simple as just creating new proxy servers. In src/helpers/ApiClient.js, it seems that all request path will get prepended with '/api', therefore they all get directed to the original proxy server. You'll need to at least make change there by adding parameters such that, depending on the parameter value, the instantiated apiclient (in src/server.js) knows which proxy server to go. However, even with that, I still failed making request to any api server other than the default path, which is localhost:3000/api. What I ended up with doing was adding separate http requests in api/actions/*.js. In current example, it returns data directly (see below).
All I did was add my own api calls there against whatever api endpoints (same domain or cross domain). Since it's from the server side, it also takes care the cross-domain browser call security issue. (see below, I'm using axios just because I'm familiar with it and it returns promise)
I'm new to this is still learning react.js and redux:) I would love to see other options that enables the flexibility of calling different api servers. For me, this approach gives me what I need with minimal change to the existing code. |
As I understand it's only possible to connect to one.
The text was updated successfully, but these errors were encountered: