httpbin.org/get request keep on called in Reacts application - reactjs

Can any one explain why a get request kept on called in Reacts application. Refer the below image.

I found out the solution, I was using a npm package "react-detect-offline" to render components based on online and offline status, that was triggering a request to check the same.

if possible could you please expand upon your question a little more, like maybe an example of your code that's making the request?
(I don't have enough rep to post comments)

Related

Typescript Multiple API's updating status in any order

I have a typescript project and I am not allowed to load additional 3rd party libraries. I can not use "useEffect" in this project as the vendor is using an older version of React if that matters.
I need to do the following:
Make an API call to Get a Token (I can do that)
Make 5 different API calls to bring back files (this can be asynchronously done as there's no order for this to be completed)
But when any of the API calls resolve then I want to update a progress bar.
When all of them have finished I will send them to another screen
I have been struggling with this and I'm trying first to grasp promises without confusing me with async / await. Sorry this is not a specific question but rather a strategy but was hoping someone can help me get further down the road. I'm hoping for an example. The more I read the more confused I get. I am a newbie.

React - Best tactic to update UI after long async POST request

After making a post request to add a blog, i then want to display those blogs on the same screen.
So there is no refresh.
What is the best way to get that updated list of blogs. Do i:
make another GET request to get the list of blogs and show a loading bar
just show the posted blog and assume the async POST will be successful
or is there a better way to tackle this?
Thanks
The best tactic really depends on the user experience and your opinion of what the new blog being on the screen might suggest to the user.
For some products, having the page move on immediately, and assuming the back-end is keeping up (eg for dragging a card to another column on a scrum board), will be the most pleasant for the user - no lag, and if the update it didn't go through and the card jumps back, no big issue.
For posting a blog though, a user might expect that if they can see their blog on the website, that that is confirmation of it going through the backend successfully. For that reason I think that another GET request is the better option, as it implicitly confirms to the user a successful POST.
It depends on the rest of your app and what you value.
The first one makes sense if you are using that same back-end controller in another part of your app that shows the blogs (maybe even before the blog is added) and you want to reuse it there.
The second one makes sense if you want to be network efficient and don't mind writing different back-end controllers for different back-end interactions. Also, you don't need to asume it will be successful, you need to catch errors and handle them.
An approach could be to do an empty post that returns the blogs but if the post has a new blog, then it is added and also returns all other blogs.

Easy Django REST Framework Websocket Usage

I have a an application that uses Angular for the frontend and communicates with an API running Django RF.
Now, let me try and outline what I'm trying to achieve in hopes of finding an easy solution.
When a user runs a report, a worker version of the API generates the report to prevent the main API from bogging down. The report runs for a couple seconds/minutes. The user refreshes the page and voila, their report is there.
What I'm trying to achieve is the elimination of the whole "user refreshes the page" portion of this process.
My goal is to do this via websockets.
I literally want something as simple as:
WEB: "Hey API, I want this report. I'll wait."
API: "Yo dog, you're reports done."
WEB: "Cool, let me refresh my report list. Thanks bud."
Now, we start to venture into an area I'm unfamiliar with. Websockets can do this, right? I just need to create a connection and wait for the all-clear to be sent by the worker.
Now, here's where it gets hairy.
I've spent the better part of the day going through libraries and just can't find what I need. The closest I've come is this, but it clashes with restframework. I get hit with tons of 404 errors and I think it has to do with the way rf manages urls.
I literally need a simple event listener. There's got to be a better way, right? To clarify, I don't want to do something brute-force like silently ping the API for report status. That gets a tad hinky. I want the API to tell me when it's ready.
In a basic way, can use something like django-websocket-redis and use Django signals to pass the messages around. ws4redis handles alot of the tricky bit. However, websockets are weird and honestly I doubt you need them. You could just poll some route that has the job state. If you need to get it done fast, I would go that route.

Three-Way Data Binding without Firebase

I am looking to make a web app where each person can add to a list and as soon as someone adds something, everyone elses browser shows the new addition.
I believe this is called 3-way data binding (I'm new to Ang). From what I can see, this can be achieved with Firebase. Is there some form of open source solution I can use that would do the same thing and is beginner friendly. I know the hacker plan on Firebase gives me 50 connections but I'm going to need more than that.
I've had a look at Deployd and Loopback.. But I'm not sure whether this would do what I want it to do.
Any help would be appreciated.
Many thanks.
Node backend option:
I haven't tried this yet myself, but Meteor offers 3 way binding and the documentation looks good:
http://angular-meteor.com/tutorials/angular1/3-way-data-binding
As long as you're using node for the backend, I imagine that you could include the Meteor library even if you're not building a full "Meteor app."
Django backend option:
Described here: https://stackoverflow.com/a/24868721/706768

Which parts of the ImgurV3 API can be used anonymously?

The documentation says:
For public read-only and anonymous resources, such as getting image info, looking up user comments, etc. all you need to do is send an authorization header with your client_id in your requests. This also works if you'd like to upload images anonymously (without the image being tied to an account), or if you'd like to create an anonymous album. This lets us know which application is accessing the API.
But it's not clear what the "etc." part includes. It's not clearly defined in the documentation. I have been using Postman to debug before putting this down in AngularJS -- this is just an AngularJS learning project for me -- and I can't get things like the gallery images for a particular subreddit. I get a status 403 back.
Anyone ever done this before?
As it turns out, if you register for an API key it doesn't take effect right away. The API key you get may not work for a few hours. (I'm guessing this is worst-case.)
It works now, with the exact same code and no changes.

Resources