小编lin*_*hnh的帖子

React Native Apollo 错误:“网络错误:网络请求失败”

在 IOS 上,应用程序运行正常。但在 Android 上,我收到此错误。这是我在客户端和服务器中的配置。请帮忙!

错误: 错误图像

这是客户端的配置:

import ApolloClient, { createNetworkInterface } from 'apollo-client';
import { SubscriptionClient, addGraphQLSubscriptions } from 'subscriptions-transport-ws';

const networkInterface = createNetworkInterface({ uri: 'http://localhost:3000/graphql' });

const wsClient = new SubscriptionClient('ws://localhost:3000/subscriptions', {
  reconnect: true,
});

const networkInterfaceWithSubscriptions = addGraphQLSubscriptions(
  networkInterface,
  wsClient,
);

export const client = new ApolloClient({
  networkInterface: networkInterfaceWithSubscriptions,
});
Run Code Online (Sandbox Code Playgroud)

这是服务器上的配置:

import express from 'express';
import {
  graphqlExpress,
  graphiqlExpress,
} from 'graphql-server-express';
import bodyParser from 'body-parser';
import cors from 'cors';
import { execute, subscribe } from …
Run Code Online (Sandbox Code Playgroud)

networking android apollo graphql react-native

6
推荐指数
2
解决办法
9716
查看次数

标签 统计

android ×1

apollo ×1

graphql ×1

networking ×1

react-native ×1