I am not able to fetch the Data from the Exchange On-chain Transfers Api of CoingGlass

Discussão em 'Angular' iniciado por Decentral NInja, Abril 5, 2025.

  1. Can someone please Help me out here in this Angular App....

    I have made a get request to fetch the data from this API of coinglass Here is the Links: https://docs.coinglass.com/reference/exchange-onchain-transfers

    But i dont know i am not able to receive the data although i have checked my Api_Url thousands of Times and Also my Api KEY but still not working then i try to create server in the project-Dir keeping both my Frontend Angular Code different and my Server different here is the code of my Server backend....I don't much about backend so please bare with me and help me out here Coders

    const express = require('express');
    const fetch = require('node-fetch'); // import node-fetch here
    const cors = require('cors');
    require('dotenv').config();

    const app = express();
    const PORT = 3000;

    app.use(cors()); // allows all origins (adjust if needed)

    app.get('/api/inflow-outflow', async (req, res) => {
    try {
    const response = await fetch('https://open-api-v3.coinglass.com/api/exchange/chain/tx/list', {
    headers: {
    accept: 'application/json',
    coinglassSecret: process.env.COINGLASS_API_KEY
    }
    });

    const data = await response.json();
    res.json(data);
    } catch (err) {
    console.error('Error fetching from CoinGlass:', err);
    res.status(500).json({ error: 'Failed to fetch CoinGlass data' });
    }
    });

    app.listen(PORT, () => {
    console.log(` Server running at http://localhost:${PORT}`);
    });


    these are the packages i installed for Servers
    "cors": "^2.8.5",
    "dotenv": "^16.4.7",
    "express": "^5.1.0",
    "node-fetch": "^3.3.2"


    Now this is my Service file code of my Angular App

    import { HttpClient, HttpHeaders } from '@angular/common/http';
    import { inject, Injectable } from '@angular/core';
    import { Observable } from 'rxjs';

    @Injectable({
    providedIn: 'root'
    })
    export class CoinglassService {

    http = inject(HttpClient)
    api_Url = 'http://localhost:3000/api/inflow-outflow';

    constructor() { }

    getTransfers(): Observable<any> {

    return this.http.get<any>(this.api_Url);
    }
    }


    And My Component code where i am subscribing and Api request

    import { Component, inject, OnInit } from '@angular/core';
    import { RouterOutlet } from '@angular/router';
    import { OnChainAlertComponent } from "./components/on-chain-alert/on-chain-alert.component";
    import { CoinglassService } from './services/coinglass.service';
    import { Api_Res, Transaction } from './model/type';

    @Component({
    selector: 'app-root',
    imports: [RouterOutlet, OnChainAlertComponent],
    templateUrl: './app.component.html',
    styleUrl: './app.component.scss'
    })
    export class AppComponent implements OnInit {
    inflowOutflowData: Transaction[] = []

    glbServ = inject(CoinglassService)


    ngOnInit(): void {
    this.loadData()

    setInterval(() => {
    this.loadData();
    }, 60000);
    }

    loadData() {
    this.glbServ.getTransfers().subscribe((res: Api_Res) => {
    this.inflowOutflowData = res.data.filter((tx: any) => ['Binance', 'Kukoin'].includes(tx.exchange))
    console.log(this.inflowOutflowData)
    })
    }
    }


    After all this whenn i check my Terminal I am getting these three errors in my Console I dont know what to do??


    1. First Error

      app.component.ts:28 ERROR HttpErrorResponse {headers: _HttpHeaders, status: 500, statusText: 'Internal Server Error', url: 'http://localhost:3000/api/inflow-outflow', ok: false, …} Zone - XMLHttpRequest.addEventListener:load
      loadData @ app.component.ts:28 ngOnInit @ app.component.ts:20 Zone - Promise.then
      (anonymous) @ main.ts:5


    2. Second Error

      requests.js:1 GET http://localhost:3000/api/inflow-outflow 500 (Internal Server Error) s.XMLHttpRequest.send @ requests.js:1 loadData @ app.component.ts:28 ngOnInit @ app.component.ts:20 Zone - Promise.then
      (anonymous) @ main.ts:5

    Continue reading...

Compartilhe esta Página