sbefort / json-odds-api

This module is for retrieving odds data from the JSON Odds API. See https://jsonodds.com for more information.
5 stars 2 forks source link

"Error Fetching results :There was a problem parsing an empty result." #4

Closed srikanth-chitturi closed 7 years ago

srikanth-chitturi commented 7 years ago

Using curl to fetch results from jsonOdds :

curl -X GET https://jsonodds.com/api/results/{39c89710-b9e8-4903-a2e7-79e0580819a2} -H "JsonOdds-API-Key: yourapikey"

[{"ID":"39c89710-b9e8-4903-a2e7-79e0580819a2","HomeScore":null,"AwayScore":null,"Final":false,"Name":"","EventID":"39c89710-b9e8-4903-a2e7-79e0580819a2","OddType":"Game","FinalType":"Not Finished"}]

But doing the same thing from jsonodds nodejs package , like :

exports.fetchResultsById = function(req, res) {
    if (!req.body.eventId) {
        res.json('Please provide eventId for this game :');
    } else {
        var options = {
            eventId: req.body.eventId,oddType: 'Game',final: true
        };
        jsonOdds.getResults(options, function(err, response, body) {
            if (err)
            {
                res.json('Error Fetching results :' + err.message);
                console.log('Error Fetching results :' + err.message);
            }
            else if (body) {
                res.json(body);
            }
            else {
                res.json('Empty');
            }
        });
    }
}

Is giving us an error message : "Error Fetching results :There was a problem parsing an empty result.". Is this a problem from the JsonOdds package ? please clarify me about this.

srikanth-chitturi commented 7 years ago

I think this is causing because we have passed options as oddType: 'Game',final: true . So the response is empty .