Reactjs 如何检查客户端是否与服务器连接

Reactjs 如何检查客户端是否与服务器连接,reactjs,apollo,react-apollo,apollo-client,Reactjs,Apollo,React Apollo,Apollo Client,我用reactjs安装了Apollo客户端。我已经在urlhttp://localhost:3044/graphql。现在我需要测试它是否连接到后端url。我该怎么做 import ApolloClient from 'apollo-boost'; import { HttpLink } from 'apollo-link-http'; import { InMemoryCache } from 'apollo-cache-inmemory'; const BASE_URL = 'http

我用reactjs安装了Apollo客户端。我已经在url
http://localhost:3044/graphql
。现在我需要测试它是否连接到后端url。我该怎么做

import  ApolloClient  from 'apollo-boost';
import { HttpLink } from 'apollo-link-http';
import { InMemoryCache } from 'apollo-cache-inmemory';

const BASE_URL = 'http://localhost:3055/graphql';
const cache = new InMemoryCache();
const httpLink = new HttpLink({
  uri: BASE_URL
});


export const client = new ApolloClient({
    uri:BASE_URL
  });

ReactDOM.render(
    <ApolloProvider client={client}>
        <App />
    </ApolloProvider>
        , document.getElementById('root'));
从“apollo boost”导入apollo客户端;
从“阿波罗链接http”导入{HttpLink};
从'apollo cache inmemory'导入{InMemoryCache};
常数基函数http://localhost:3055/graphql';
常量缓存=新的InMemoryCache();
const httpLink=新的httpLink({
uri:基本URL
});
export const client=新客户端({
uri:基本URL
});
ReactDOM.render(
,document.getElementById('root');

谢谢你

是否只需要测试,或者如果后端仍在运行,是否正在寻找从客户端进行监视的方法?只是测试:监视:我不太确定您的情况是什么,但我认为您可以通过错误处理来验证后端是否有问题。“希望这能有所帮助。”马斯梅里诺谢谢你的回复。我会检查并让您知道+1