Discord
Login
Community
DARK THEME

Connect With External API

Halo guys, i'm new here. Maybe some one already tried to connect with external api ?

Regards

https://microstudio.dev/i/DeRaNGeR/httprequest/

https://microstudio.dev/i/Romero/serialportapiformicroscript/

There used to be a game here that saved the best results on the server via an API provided by the server.

Does anyone remember its name?

Are you trying to connect to the MicroStudio API or connect to an external API from MicroStudio?

Yes, did you ever do that ? i wanna save any progress to database or other apps integration by using API

Check out the JavaScript Fetch API. Here's a simple interface for MicroScript:

//javascript
global.fetch = function(resource, callback, options={}) {
  let result = { ready: false }
  fetch(resource).then(async (response) => {
    const text = await response.text();
    result.ready = true;
    result.data = text;
    callback(text);
  });
  return result;
}

It can also be modified to return other data such as response status.

> fetch("https://api.ipify.org", print)
object
  ready = 0
end
[your public IP address]

However, to connect with a database, you may need to host your own server so as not to disclose your database credentials.

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community