Jump to content
McKay Development

Recommended Posts

Posted

Good day,

I have been trying to make a function that searches for a random item on the steam market, I ran into an issue. Here is the error:

C:\Users\Ernest\Desktop\SteamBot\Current Version\node_modules\steamcommunity\classes\CMarketSearchResult.js:62
                                callback(new Error($errorMsg.text()));
                                ^

TypeError: callback is not a function
    at SteamCommunity.<anonymous> (C:\Users\Ernest\Desktop\SteamBot\Current Version\node_modules\steamcommunity\classes\CMarketSearchResult.js:62:5)
    at Request._callback (C:\Users\Ernest\Desktop\SteamBot\Current Version\node_modules\steamcommunity\components\http.js:67:15)
    at Request.self.callback (C:\Users\Ernest\Desktop\SteamBot\Current Version\node_modules\request\request.js:185:22)
    at Request.emit (events.js:315:20)
    at Request.<anonymous> (C:\Users\Ernest\Desktop\SteamBot\Current Version\node_modules\request\request.js:1154:10)
    at Request.emit (events.js:315:20)
    at Gunzip.<anonymous> (C:\Users\Ernest\Desktop\SteamBot\Current Version\node_modules\request\request.js:1076:12)
    at Object.onceWrapper (events.js:421:28)
    at Gunzip.emit (events.js:315:20)
    at endReadableNT (internal/streams/readable.js:1327:12)

C:\Users\Ernest\Desktop\SteamBot\Current Version>pause
Press any key to continue . . .

 

Looking at the code here is what I see:

function performSearch() {
        self.httpRequest({
            "uri""https://steamcommunity.com/market/search/render/",
            "qs": qs,
            "headers": {
                "referer""https://steamcommunity.com/market/search"
            },
            "json"true
        }, function(err, response, body) {
            if (err) {
                callback(err);
                return;
            }
 
            if(!body.success) {
                callback(new Error("Success is not true"));
                return;
            }
 
            if(!body.results_html) {
                callback(new Error("No results_html in response"));
                return;
            }
 
            var $ = Cheerio.load(body.results_html);
            var $errorMsg = $('.market_listing_table_message');
            if($errorMsg.length > 0) {
                callback(new Error($errorMsg.text()));
                return;
            }
 
            var rows = $('.market_listing_row_link');
            for(var i = 0; i < rows.length; i++) {
                results.push(new CMarketSearchResult($(rows)));
            }
 
            if(body.start + body.pagesize >= body.total_count) {
                callback(null, results);
            } else {
                qs.start += body.pagesize;
                performSearch();
            }
        }, "steamcommunity");
    }
};

Here is my code:

    community.marketSearch(query, 730falsefunction(err, items) {
        if (err) {
            console.log(err)
        } else {
            console.log(items)
            resolve(items);
        }
    })
    })

I don't think there is anything wrong with my code, any ideas?

Posted (edited)
14 hours ago, Dr. McKay said:

The mistake is in your code. marketSearch only takes two arguments, options and callback. Remove the 730 and false.

Thanks! I appreciate the help

Edit: I got everything figured out :)

Edited by What Comes Around
Posted (edited)

Is there a way to get all the items on the steam market for CSGO? I have tried omitting query string and using '' (so nothing), but got back some error. I think it was there are no items with that keyword or something.

Edited by What Comes Around

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...