Web standards
Check which native JavaScript objects a function can use in Azion Runtime, and which timer argument the runtime refuses.
Azion Runtime runs JavaScript built on Web standards, so the native JavaScript APIs, such as the Math and JSON objects, are available to a function. For the global objects the runtime defines, refer to Globals. For more information on the language, refer to JavaScript reference on MDN Web Docs.
Native JavaScript and Web APIs
Native JavaScript objects and the Web APIs of the runtime work together in one function. A function parses a request body with JSON, computes values with Math, Date, and String, and returns the result with Response. For the Web APIs that Azion Runtime supports, refer to Web APIs. For the standard definitions of those APIs, refer to Web APIs on MDN Web Docs.
Timer callbacks
A deployed function refuses a string as the callback of setTimeout() or setInterval(). The call throws EvalError: eval not allowed on setTimeout/setInterval parameter. Pass a function as the callback instead.
Use cases
- Parse and serialize payloads with the
JSONobject as requests pass through a function. - Calculate, format, and transform data with the standard
Math,Date, andStringmethods. - Write portable logic, test it under
azion dev, and confirm it on a deployed function. For the APIs that behave differently on each side, refer to How Azion Runtime works. - Combine native language features with the supported Web APIs to build responses on Azion’s distributed infrastructure.
Example
This handler passes a string to setTimeout(), catches the error the call throws, and returns the error as the response text:
A deployed function returns this text: