Dashboards & Visualizations

Why am I getting a TypeError: k is undefined when working with the spunk sdk for javascript?

syx093
Communicator

I have been using one of the examples from splunk as a based in order to log into splunk and list my apps. However, I keep getting a TyperError: k is undefined. What is the reasoning to getting this error.

<html>
<head>
<meta charset="utf-8">
<title>How to start a Splunk session</title>

<script type="text/javascript" src="/home/sxiong/Documents/splunk_java_script/splunk-sdk-javascript-master/client/splunk.min.js"></script>
<script type="text/javascript" src="/home/sxiong/Documents/splunk_java_script/splunk-sdk-javascript-master/examples/browser/resources/jquery.min.js"></script>

<script type="text/javascript" charset="utf-8">
console.log("printing");
var http = new splunkjs.ProxyHttp("/proxy");
var service = new splunkjs.Service(http, {
username: 'admin',
password: 'changeme',
scheme: 'https',
host: 'megaman',
port: 8000,
version: '6.2.4'
});
console.log("print please");
if ( window.console && window.console.log ) {
    // console is available
    console.log("we are getting started"); 
}
console.log("we are getting started"); 
// First, we log in
service.login(function(err, success) {
        // We check for both errors in the connection as well
        // as if the login itself failed.
        if (err || !success) {
        console.log("Login failure. Please check your server hostname and authentication credentials.");
        done(err || "Login failed");
        return;
        } 
        console.log("we did it yeah stuff"); 
        // Now that we're logged in, let's get a listing of all the apps.
        service.apps().fetch(function(err, apps) {
            if (err) {
            console.log("There was an error retrieving the list of applications:", err);
            done(err);
            return;
            }

            var appsList = apps.list();
            console.log("Applications:");
            for(var i = 0; i < appsList.length; i++) {
            var app = appsList[i];
            console.log("  App " + i + ": " + app.name);
            } 

            done();
            });
});

</script>
</head>
</html><html>
<head>
<meta charset="utf-8">
<title>How to start a Splunk session</title>

<script type="text/javascript" src="/home/sxiong/Documents/splunk_java_script/splunk-sdk-javascript-master/client/splunk.min.js"></script>
<script type="text/javascript" src="/home/sxiong/Documents/splunk_java_script/splunk-sdk-javascript-master/examples/browser/resources/jquery.min.js"></script>

<script type="text/javascript" charset="utf-8">
console.log("printing");
var http = new splunkjs.ProxyHttp("/proxy");
var service = new splunkjs.Service(http, {
username: 'admin',
password: 'changeme',
scheme: 'https',
host: 'megaman',
port: 8000,
version: '6.2.4'
});
console.log("print please");
if ( window.console && window.console.log ) {
    // console is available
    console.log("we are getting started"); 
}
console.log("we are getting started"); 
// First, we log in
service.login(function(err, success) {
        // We check for both errors in the connection as well
        // as if the login itself failed.
        if (err || !success) {
        console.log("Login failure. Please check your server hostname and authentication credentials.");
        done(err || "Login failed");
        return;
        } 
        console.log("we did it yeah stuff"); 
        // Now that we're logged in, let's get a listing of all the apps.
        service.apps().fetch(function(err, apps) {
            if (err) {
            console.log("There was an error retrieving the list of applications:", err);
            done(err);
            return;
            }

            var appsList = apps.list();
            console.log("Applications:");
            for(var i = 0; i < appsList.length; i++) {
            var app = appsList[i];
            console.log("  App " + i + ": " + app.name);
            } 

            done();
            });
});

</script>
</head>
</html>
Tags (2)
0 Karma
1 Solution

syx093
Communicator

Never mind I fixed it. Turns out I was using splunk.min.js instead of splunk.js. What I find stupid is why does splunk.js comes with a bug.

View solution in original post

0 Karma

syx093
Communicator

Never mind I fixed it. Turns out I was using splunk.min.js instead of splunk.js. What I find stupid is why does splunk.js comes with a bug.

0 Karma
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...