Comments (11)
Why do you think http
is only available on client side?
from react-pages.
I know that it's universal but as I understand this utility is available only in your middleware for async actions, and i want something like this in redux-thunk
I've tried to use getHttpClient()
but it gave me an error that window is not defined on server side.
from react-pages.
I know that it's universal but as I understand this utility is avilable only in your middleware for async actions, and i want something like this in redux-thunk
I see.
Well, there is no global
variable on server-side so getHttpClient()
doesn't work there.
Instead, http
client could be stored somewhere in store
, like store.httpClient = httpClient
but then how would one access store
from an action... I guess it's not correct to access store
from an action. In Redux, there's no way actually to access store
directly, only getState()
, but httpClient
can't be stored in state because it's not a JSON object.
from react-pages.
I'll close this for now as "not possible".
Still you can write comments here.
from react-pages.
ok, thanks
Yeah, that's it
I found something like workaround for this
workaround is to export some global variable (for example httpUtility) in source / redux / store.js
and to set
httpUtility = http_client
inside create_store function
it solves my needs
But i want it to be in npm package
Could you please add this in new version?
I think that this workaround is ok as i understand because we will use httpUtility always after the store is created
and it always gonna return correct http utility as on client and as on server
from react-pages.
I don't understand, which exact variable do you set inside create_store function.
You can post some actual code.
from react-pages.
something like this in source / redux / store.js
from react-pages.
You can't share an httpClient
between several users.
If you store it in a global variable then many users are using it simultaneously.
It's not supposed to be used like that: it should be constructed anew for each page for each user.
from react-pages.
I get it, ok i will use common react-website approach for async actions.
thanks :)
from react-pages.
You should be able to do anything using the common react-website approach for async actions.
If there's a use-case where something is not possible then you can post it here.
from react-pages.
ok, thanks
from react-pages.
Related Issues (20)
- Access store outside React scope HOT 4
- Adding json-ld script tags (dynamic) in SSR pages HOT 1
- Can't add custom handler for `@@react-isomorphic-render/goto` event HOT 4
- Error running npm install HOT 1
- The test is failed. (npm install) HOT 1
- usage directions fail at npm install babel-node HOT 1
- SSR middlewares HOT 2
- react-router problem HOT 7
- how can i run this site? HOT 8
- How modify @preload {client: true} configuration HOT 5
- How to capture an event type HOT 2
- Crash in long running production process (v 2.0.13) HOT 2
- Module not found: Error: Can't resolve './aboutPageReducer' in ...... HOT 1
- Error instantiating router HOT 5
- No way to detect authentication before using http client HOT 2
- [SSR] Access to the request headers HOT 4
- Enable configuration entry for HTTP `on_before_send` HOT 8
- Invalid Content-Type for get and multipart requests HOT 3
- Moving from isomorphic to website causes render service error HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-pages.