net core users, the WebAPI should have the attribute set on the action and the method should be allowed in the Startup.cs file and Web.config.Įxample of handlers in web. So please make sure both http verbs are allowed in your API.įor. This is called using http HEAD GET request. The above example will ping every 10 seconds to check for online status. Learn React Nanodegree Program Become a successful React developer by learning to build declarative user interfaces for the web with React and manage state more predictably in your applications with Redux. say this code is inside constants.js file under common folder.Įxport const APIUrl = " export const pingUrl = APIUrl + "/ping" Įxport const polling = from "./Common/Constants" You can also change the timeout setting but I’ve not used it here in the polling object. You can however change a few settings including the ping URL, enabled boolean and interval for ping duration. It uses a default polling url to check whether you’re online. There is a very cool react package react-detect-offline available on npm that helps with this. May be you need to just show a message to the user that the Internet connection is disrupted. It is a very common scenario to check whether the user is online while using your Web Application to make it robust.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |