We are calling a payment gateway api and that vendor is sending response with some POST method. Our UI is build in react which is not able to consume that data. How can I do that?
Assuming this is CCAvenue, you will need a server to take that response and redirect you back to React with the necessary details.
If I get your question right, here it's better if they send it using GET. If you want to consume the data then this is the right way.
Related
I try to understand how could i override default behavior of React Query if for example i made reguest (query or mutation ) => and it recieved 401 Unathorization. I understand that i need to send request to get new access token based on my refresh token which i already have in my localstorage.
I could trigger it every time just write logic if onError and then try request once again with new accessToken.
But my app have more than 1000+ requests that i need to add this logic. And i wonder how i can make it in one place by default. Probably in Middleware or something like this (I'm new in React). Please share any kind of suitable solution.
Thank you in advance
The recommended approach right now is to not couple this logic with react-query, but with the actual library that does the data fetching for you. If you use for example axios - it offers interceptors. There are also some good suggestions in this discussion about async retries.
I am new to react-query and appreciate the way it caches the api response. I am just curious , is there an out-of-the-box way to cache a formatted version (more suitable to frontend) of api response than the response itself?
We use to do that in react-redux where we can cache something in store in a specific format so that interested react components can read that formatted value.
Any clues?
you can return whatever promise you want from the queryFn - it doesn't have to be the exact api response. Transformations can be done, too.
I've done an extensive write-up on this topic: https://tkdodo.eu/blog/react-query-data-transformations
I'm working on a project with .net-core backend and react/react-native for frontend/mobile. On frontend we use axios for api client. The problem we've got was with HTTP GET method. We wanted to send GET with data in body instead of URL params as it was easier to parse it in backend, but for some reason axios was having problem with dealing with it this way. Now our current solution is to use PATCH instead of GET and want to ask if it is a good/acceptable practice - and if not, what would be the best workaround for this problem?
New to Angular and want to understand more about it. I know Ajax can have real time effect by basically repeatedly sending Http requests to server on short time intervals. Can I achieve similar real-time effect using Angular? If true to previous question, how does Angular achieve the real-time effect? Is it the same as Ajax?
In order to be realtime you would need to have server code that pushes data to applications. Angular, which is client side javascript, will only have the ability to pull.
Hmm, I think you should Google some defination about, Ajax, Realtime, and might be Framework also.
But basiclly, AJAX not is realtime. In a deep, It's only effect which make better experience for user. In addition, it's related to Single Page Application.
Realtime is action interactive with many users. The best example you can see is Facebook, chat or notification. User 1 can send message and User 2 can see instantly, no need to reload. Diffirent for AJAX, User 2 can not see the message if he don't reload browser.
About part 2 of your question, after understanding AJAX, realtime. You can use some third party like Socket, Firebase ... which able to use realtime for your Angular app.
I want to package that data from the user input form into JSON and post it to a remote server. Could anybody either show me an example or direct me to a tutorial that shows how to do this?
I know this is not why SO is for, but to help you i'll put a link here:
http://tutsnare.com/post-form-data-using-angularjs/
You can use Google next time.