0

我正在尝试从 OpenSea 获得响应并继续执行我的任务,但每次我向 OpenSea 发送请求时都会收到类似的信息 - 我想这可能会发生,因为 OpenSea 需要一些密钥或类似的东西,但我不确定...

async function start() {
    const express = require("express")
    const app = express();
    const Moralis = require('moralis/node');
    const https = require('https');

    try {

        await Moralis.start({
            serverUrl: "https://..../server",
            appId: "My...",
            masterKey: "cMD...",
            xAPI_key: "tDP..."
        });

        const options = { chain: 'matic', address: '0x1b3907db0a6b842850f1392df8845028b8ed980a' };
        await Moralis.Web3API.account.getNFTs(options)
            .then(res => {
                console.log(res.result.map(data => {

                    const id = data.token_id;
                    const address = data.token_address;

                    console.log(address, id, "address and id here")

                    let URL = `https://opensea.io/assets/matic/${address}/${id}`;

                    console.log(URL, "URL here");

                    const options = {
                        hostname: 'api.opensea.io',
                        path: URL,
                        method: 'GET'
                    }

                    const req = https.request(options, res => {
                        console.log(`statusCode: ${res.statusCode}`)

                        res.on('data', d => {
                            process.stdout.write(d)
                        })
                    })

                    req.on('error', error => {
                        console.error(error)
                    })

                    req.end()
                }))
            })

    } catch (err) {
        console.log(err, "eeeeeeeerrrr")
    }

    const PORT = process.env.PORT || 5007;

    app.listen(PORT, () => console.log(`Server starts here - ${PORT}`));
}
start();
4

0 回答 0