Skip to content

Make calls to jsonapi using Javascript #468

Open
@ersgonzalo

Description

@ersgonzalo

Hey Mates,

I'm a bit unsure of how to make calls to the JSON Api on my server using Javascript. I want to make more information available on my server's website and take it from the server itself without having to use external services. If this information is documented in the Wiki forgive me for my ignorance but I can't seem to find any at the moment. From what I can gather, process for making a call to a Minecraft server seems to be as so:

  • Install the JSONAPI Plugin to your server (along with the other dependencies as needed)
  • Look into configuration files and save the username and password in the users.yml file for later use
  • If you want to use a salt, include a salt in the config.yml file
  • Look into the Javascript SDK from tools and load it as one of the scripts for the index.html
  • In my own script.js file, insert this:
    var j = new jsonapi({ hostname: "serverIP/domainName", port: 20059, username: "usernameFromUsers.yml", password: "passwordFromUsers.yml", salt: "saltFromConfig.yml" });
  • And then make calls, like so: j.call('getPlayers', console.log);

However, I seem to get errors with my server and nothing is returned from my get requests. Could I get some help with this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions