DocumentServer icon indicating copy to clipboard operation
DocumentServer copied to clipboard

[Custom Functions] XMLHttpRequest does not work

Open digg33 opened this issue 7 months ago • 1 comments

This issue is unique.

  • [X] I have used the search tool and did not find an issue describing my bug.

Operating System of DocumentServer

Docker

Version information

8.1.1.27

Expected Behavior

New feature in 8.1. Expected to obtain value from XMLHttpRequest responseText field after calling send() method. The testfn() function works correctly in Chrome browser console.

Actual Behavior

#VALUE shown in cell.

Reproduction Steps

  1. Create a new custom function (Plugins -> Macros -> Custom functions) and paste the following:
(function()
{
	/**
	 * Function that returns 69
	 * @customfunction
	 * @returns {any} 69.
	 */
	function testfn() {
	    const xhr = new XMLHttpRequest();
	    xhr.open('GET', 'https://httpbin.org/get?a=69', false);
	    xhr.send();
	    return JSON.parse(xhr.responseText).args.a;
	}
	Api.AddCustomFunction(testfn);
})();
  1. In an empty cell, type =TESTFN()

Additional information

No response

digg33 avatar Jul 24 '24 18:07 digg33