Hello I have a plugin (in spoiler) that I'm simply trying to load data from a url in javascript. Not sure if this works at all in RPG maker, but I can load the plugin and get the console log that it's loaded. I can add the plugin command to an event and the rest of the event runs fine till it gets to the plugin then simply nothing, not an error, not a console log or anything.
Code:
/*:
* @target MZ
* @plugindesc Example plugin to send fetch commands in RPG Maker MZ.
* @help FetchExample.js
*
* This plugin demonstrates how to use the fetch API to make HTTP requests.
*
* @command fetchData
* @text Fetch Data
* @desc Fetch data from a specified URL.
*
* @arg url
* @text URL
* @desc The URL to fetch data from.
* @type string
* @default https://jsonplaceholder.typicode.com/todos/1
*/
(() => {
'use strict';
const pluginName = 'FetchExample';
console.log('FetchExample plugin loaded');
PluginManager.registerCommand(pluginName, 'fetchData', args => {
const url = args.url;
console.log('FetchExample plugin loaded', url);
fetch(url)
.then(response => response.json())
.then(data => {
console.log('Fetched data:', data);
$gameMessage.add('Data fetched successfully!');
})
.catch(error => {
console.error('Error fetching data:', error);
$gameMessage.add('Failed to fetch data.');
});
});
})();