草庐IT

Apollo-client

全部标签

node.js - Node js - Socket.io-client 未连接到 socket.io 服务器

我正在尝试使用以下代码连接到socket.io-client:服务器://Loadrequirementsvarhttp=require('http'),io=require('socket.io');//Createserver&socketvarserver=http.createServer(function(req,res){//SendHTMLheadersandmessageres.writeHead(404,{'Content-Type':'text/html'});res.end('Aw,snap!404');});server.listen(8080);io=io.l

node.js - Node js - Socket.io-client 未连接到 socket.io 服务器

我正在尝试使用以下代码连接到socket.io-client:服务器://Loadrequirementsvarhttp=require('http'),io=require('socket.io');//Createserver&socketvarserver=http.createServer(function(req,res){//SendHTMLheadersandmessageres.writeHead(404,{'Content-Type':'text/html'});res.end('Aw,snap!404');});server.listen(8080);io=io.l

node.js - 将 ApolloClient 与 node.js 一起使用。 "fetch is not found globally and no fetcher passed"

我正在尝试在node.js服务器上使用Apollo客户端来使用以下代码与另一个GraphQLAPI进行交互:importfetchfrom'node-fetch'import{createHttpLink}from'apollo-link-http'importApolloClientfrom'apollo-boost'import{API_URL}from'...'constclient=newApolloClient({link:createHttpLink({uri:API_URL,fetch:fetch,}),})这会产生以下错误:moduleinitializationerr

node.js - 将 ApolloClient 与 node.js 一起使用。 "fetch is not found globally and no fetcher passed"

我正在尝试在node.js服务器上使用Apollo客户端来使用以下代码与另一个GraphQLAPI进行交互:importfetchfrom'node-fetch'import{createHttpLink}from'apollo-link-http'importApolloClientfrom'apollo-boost'import{API_URL}from'...'constclient=newApolloClient({link:createHttpLink({uri:API_URL,fetch:fetch,}),})这会产生以下错误:moduleinitializationerr

node.js - 错误 : Cannot find module 'npm-registry-client'

每当我尝试安装npm-registry-client时,都会收到错误“错误:找不到模块'npm-registry-client'”。我已尝试使用以下命令解决此问题,但这不起作用:npm卸载npminstall-gnpm@latest完整的输出是:user@pc~/devel>npminstallnpm-registry-client--savemodule.js:340throwerr;^Error:Cannotfindmodule'npm-registry-client'atFunction.Module._resolveFilename(module.js:338:15)atFun

node.js - 错误 : Cannot find module 'npm-registry-client'

每当我尝试安装npm-registry-client时,都会收到错误“错误:找不到模块'npm-registry-client'”。我已尝试使用以下命令解决此问题,但这不起作用:npm卸载npminstall-gnpm@latest完整的输出是:user@pc~/devel>npminstallnpm-registry-client--savemodule.js:340throwerr;^Error:Cannotfindmodule'npm-registry-client'atFunction.Module._resolveFilename(module.js:338:15)atFun

Node.js socket.io-client connect_failed/connect_error 事件

我在玩node.js和socket.io-client。我正在尝试连接到不存在的channel以触发事件“connect_failed”(在https://github.com/LearnBoost/socket.io-client中指定)。但是我无法让事件正常进行:varclientio=require('socket.io-client');console.log('Tryingstuff...');//thechanneldoesnotexistvarsocket=clientio.connect('http://localhost:4000/news');//Iexpectth

Node.js socket.io-client connect_failed/connect_error 事件

我在玩node.js和socket.io-client。我正在尝试连接到不存在的channel以触发事件“connect_failed”(在https://github.com/LearnBoost/socket.io-client中指定)。但是我无法让事件正常进行:varclientio=require('socket.io-client');console.log('Tryingstuff...');//thechanneldoesnotexistvarsocket=clientio.connect('http://localhost:4000/news');//Iexpectth

javascript - Socket IO 房间 : Get list of clients in specific room

我正在尝试显示特定房间中的客户列表。我只想显示他们的用户名,而不是他们的套接字ID。我现在的位置:socket.set('nickname',"Earl");socket.join('chatroom1');console.log('Userjoinedchatroom1);varroster=io.sockets.clients('chatroom1');for(iinroster){console.log('Username:'+roster[i]);}没有任何运气让它列出套接字ID或任何东西。但是希望它返回昵称。 最佳答案 在

javascript - Socket IO 房间 : Get list of clients in specific room

我正在尝试显示特定房间中的客户列表。我只想显示他们的用户名,而不是他们的套接字ID。我现在的位置:socket.set('nickname',"Earl");socket.join('chatroom1');console.log('Userjoinedchatroom1);varroster=io.sockets.clients('chatroom1');for(iinroster){console.log('Username:'+roster[i]);}没有任何运气让它列出套接字ID或任何东西。但是希望它返回昵称。 最佳答案 在