getPeers Query
參數
此方法不接受任何參數
退貨
資料
物件
載入中...
nodeInfo
物件
載入中...
peers
陣列
載入中...
id
字串
載入中...
請求
1curl --location 'https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql' \2--header 'Accept: application/json' \3--標頭 'Content-Type: application/json' \4--data '{5"query": "{ nodeInfo { peers { id } } }"6}'
1curl --location 'https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql' \2--header 'Accept: application/json' \3--標頭 'Content-Type: application/json' \4--data '{5"query": "{ nodeInfo { peers { id } } }"6}'
1const PEERS_QUERY = `2query {3nodeInfo {4peers {5id6}7}8}9`;1011const fetchNodePeers = async (): Promise<void> => {12try {13const response = await fetch('https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql', {14method: 'POST',15headers: {16'Accept': 'application/json',17'Content-Type': 'application/json',18},19body: JSON.stringify({20query: PEERS_QUERY,21}),22});2324if (!response.ok) {25throw new Error(`HTTP error! status: ${response.status}`);26}2728const result = await response.json();29console.log('Peers:', result.data.nodeInfo.peers);30} catch (error) {31console.error('Error fetching node peers:', error);32}33};3435fetchNodePeers();36
1const PEERS_QUERY = `2query {3nodeInfo {4peers {5id6}7}8}9`;1011const fetchNodePeers = async (): Promise<void> => {12try {13const response = await fetch('https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql', {14method: 'POST',15headers: {16'Accept': 'application/json',17'Content-Type': 'application/json',18},19body: JSON.stringify({20query: PEERS_QUERY,21}),22});2324if (!response.ok) {25throw new Error(`HTTP error! status: ${response.status}`);26}2728const result = await response.json();29console.log('Peers:', result.data.nodeInfo.peers);30} catch (error) {31console.error('Error fetching node peers:', error);32}33};3435fetchNodePeers();36
1const myHeaders = new Headers();2myHeaders.append("Accept", "application/json");3myHeaders.追加("Content-Type", "application/json");45const raw = JSON.stringify({6"query": "{ nodeInfo { peers { id } } }"7});89const requestOptions = {10method: "POST",11標題: myHeaders,12正文: 原始,13重定向: 「追蹤」14};1516fetch("https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql", requestOptions)17.接著((回應) => 回應.文字())18.接著((結果) => 控制台.log(結果))19.catch((錯誤) => 控制台.錯誤(錯誤));
1const myHeaders = new Headers();2myHeaders.append("Accept", "application/json");3myHeaders.追加("Content-Type", "application/json");45const raw = JSON.stringify({6"query": "{ nodeInfo { peers { id } } }"7});89const requestOptions = {10method: "POST",11標題: myHeaders,12正文: 原始,13重定向: 「追蹤」14};1516fetch("https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql", requestOptions)17.接著((回應) => 回應.文字())18.接著((結果) => 控制台.log(結果))19.catch((錯誤) => 控制台.錯誤(錯誤));
1const { ApolloClient, InMemoryCache, gql } = require('@apollo/client/core');2const fetch = require('cross-fetch');34const client = new ApolloClient({5uri: 'https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql',6cache: new InMemoryCache(),7fetch: fetch,8headers: {9'Accept': 'application/json',10'Content-Type': 'application/json'11}12});1314const NODE_INFO_QUERY = gql`15{16nodeInfo {17peers {18id19}20}21}22`;2324client.query({25query: NODE_INFO_QUERY26})27.then(result => {28console.log('Node Info (Peers):', JSON.stringify(result.data, null, 2));29})30.catch(error => console.error('Error:', error));
1const { ApolloClient, InMemoryCache, gql } = require('@apollo/client/core');2const fetch = require('cross-fetch');34const client = new ApolloClient({5uri: 'https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql',6cache: new InMemoryCache(),7fetch: fetch,8headers: {9'Accept': 'application/json',10'Content-Type': 'application/json'11}12});1314const NODE_INFO_QUERY = gql`15{16nodeInfo {17peers {18id19}20}21}22`;2324client.query({25query: NODE_INFO_QUERY26})27.then(result => {28console.log('Node Info (Peers):', JSON.stringify(result.data, null, 2));29})30.catch(error => console.error('Error:', error));
1匯入 請求2匯入 json34url = "https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql"56有效載荷 = json.dumps({7"query": "{ nodeInfo { peers { id } } }"8})9標題 = {10'Accept': 'application/json',11「Content-Type」: 'application/json'12}1314回應 = 請求.請求("POST", url, headers=headers, data=有效載荷)1516列印(回應.text)17
1匯入 請求2匯入 json34url = "https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql"56有效載荷 = json.dumps({7"query": "{ nodeInfo { peers { id } } }"8})9標題 = {10'Accept': 'application/json',11「Content-Type」: 'application/json'12}1314回應 = 請求.請求("POST", url, headers=headers, data=有效載荷)1516列印(回應.text)17
1需要 "uri"2require "json"3需要 "net/http"45url = URI("https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql")67https = 網::HTTP.new(url.主機, 網址.port)8https.use_ssl = true910請求 = 淨額::HTTP::POST.新增(網址)11請求[「接受」] = "application/json"12請求["Content-Type"] = "application/json"13請求。主體 = JSON.dump({14"query": "{ nodeInfo { peers { id } } }"15})1617回應 = https.請求(請求)18puts 回應。read_body19
1需要 "uri"2require "json"3需要 "net/http"45url = URI("https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql")67https = 網::HTTP.new(url.主機, 網址.port)8https.use_ssl = true910請求 = 淨額::HTTP::POST.新增(網址)11請求[「接受」] = "application/json"12請求["Content-Type"] = "application/json"13請求。主體 = JSON.dump({14"query": "{ nodeInfo { peers { id } } }"15})1617回應 = https.請求(請求)18puts 回應。read_body19