Giter Club home page Giter Club logo

Comments (17)

Lierrmm avatar Lierrmm commented on August 26, 2024

Make sure you have the latest version with npm i call-of-duty-api@latest.
This issue was fixed with the latest release.

from node-callofduty.

M0in4 avatar M0in4 commented on August 26, 2024

I have updated to the latest update and I've got the same error

from node-callofduty.

Lierrmm avatar Lierrmm commented on August 26, 2024

Can you send an example of the whole script you are using?

from node-callofduty.

M0in4 avatar M0in4 commented on August 26, 2024
var express = require('express');
var router = express.Router();
const API = require('call-of-duty-api')();

router.get('/:username/:game', function(req, res, next) {
	var username = req.params.username;
	var game = req.params.game;
	var apiGame = API.platforms.battle;
	console.log(apiGame);
	if (game == "battle") {
		apiGame = API.platforms.battle;
	}
	else if (game == "steam") {
		apiGame = API.platforms.steam;
	}
	else if (game == "psn") {
		apiGame = API.platforms.psn;
	}
	
	function receiveStats() {
		API.MWwz(username, apiGame).then(data => {
			console.log(data);  // see output
			return res.status(202).json({
				"error": "nil",
				"response": data
			});
		}).catch (err => {
			console.log(err);
			return res.status(202).json({
				"error": err,
				"response": "nil"
			});
		});
	}
	
	receiveStats();
});
module.exports = router;

from node-callofduty.

Lierrmm avatar Lierrmm commented on August 26, 2024

Have you got an example user?

This is my test case which works as intended.

const api = require('call-of-duty-api')();
const user = "Lierrmm425324";

test = () => {
    let username = user;
    let apiGame = api.platforms.battle;

    api.MWwz(username, apiGame).then(data => {
        console.log(data);  // see output
        return JSON.stringify({
            "error": "nil",
            "response": data
        });
    }).catch (err => {
        console.log(err);
        return JSON.stringify({
            "error": err,
            "response": "nil"
        });
    });
};

console.log(test());

output

[ br: {}, br_dmz: {}, br_all: {} ]

from node-callofduty.

M0in4 avatar M0in4 commented on August 26, 2024

Its giving error with your username too with my code.
I got same error with your code

from node-callofduty.

Lierrmm avatar Lierrmm commented on August 26, 2024

What version of the api are you using? it will say in package.json

from node-callofduty.

M0in4 avatar M0in4 commented on August 26, 2024

1.0.25

from node-callofduty.

Lierrmm avatar Lierrmm commented on August 26, 2024

Hmm, Weird.

I'd suggest doing a clean uninstall so npm uninstall call-of-duty-api and
then npm i call-of-duty-api@latest.

from node-callofduty.

M0in4 avatar M0in4 commented on August 26, 2024

Done, same error...

	function receiveStats() {
		test = () => {
		    API.MWwz("Lierrmm425324", API.platforms.battle).then(data => {
		        console.log(data);  // see output
		        return JSON.stringify({
		            "error": "nil",
		            "response": data
		        });
		    }).catch (err => {
		        console.log(err);
		        return JSON.stringify({
		            "error": err,
		            "response": "nil"
		        });
		    });
		};

		console.log(test());
	}

Error:
Cannot read property 'mode' of undefined call-of-duty-api/index.js:187:41

from node-callofduty.

Lierrmm avatar Lierrmm commented on August 26, 2024

Can you navigate to node_modules/call-of-duty-api/index.js and go to line 187 and send a screenshot please.

from node-callofduty.

M0in4 avatar M0in4 commented on August 26, 2024
    module.MWwz = function (gamertag, platform = config.platform) {
        return new Promise((resolve, reject) => {
            brDetails = [];
            brDetails.br = {};
            brDetails.br_dmz = {};
            brDetails.br_all = {};
            this.MWmp(gamertag, platform).then((data) => {
                if(typeof data.lifetime.mode.br) { data.lifetime.mode.br.properties.title = "br"; brDetails.br = data.lifetime.mode.br.properties; }
                if(typeof data.lifetime.mode.br_dmz) { data.lifetime.mode.br_dmz.properties.title = "br_dmz"; brDetails.br_dmz = data.lifetime.mode.br_dmz.properties; }
                if(typeof data.lifetime.mode.br_all) { data.lifetime.mode.br_all.properties.title = "br_all"; brDetails.br_all = data.lifetime.mode.br_all.properties; }
                resolve(brDetails);
            }).catch(e => reject(e));
        });
    };


Line 187: if(typeof data.lifetime.mode.br) { data.lifetime.mode.br.properties.title = "br"; brDetails.br = data.lifetime.mode.br.properties; }

from node-callofduty.

Lierrmm avatar Lierrmm commented on August 26, 2024

Yes, that is not on the latest version. If you look at this line you can see the implemented fix:

if(typeof data.lifetime !== "undefined") {

from node-callofduty.

M0in4 avatar M0in4 commented on August 26, 2024

Is your npm updated or its updated only on GitHub?

from node-callofduty.

Lierrmm avatar Lierrmm commented on August 26, 2024

It was updated on NPM too.

I have published it again, could you try updating it to 1.0.26 please

from node-callofduty.

M0in4 avatar M0in4 commented on August 26, 2024

I'll try soon.
I've edited it manually for now and its retrieving null stats for all username.
Have you got some username to test with?

from node-callofduty.

Lierrmm avatar Lierrmm commented on August 26, 2024

Lierrmm#2364

from node-callofduty.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.