文档

支持

Cloud Code

与外部服务集成

Call public internet endpoints and public APIs from your Cloud Code scripts.
阅读时间1 分钟最后更新于 1 个月前

借助 Cloud Code,您可以调用任何公共互联网终端,包括属于 UGS 的公共 API 以下示例演示了如何调用 Cat Facts API 以获取随机 cat fact。
JavaScript
const axios = require("axios-0.21");module.exports = async ({ params, context, logger }) => { let result; try { const catFactUrl = `https://catfact.ninja/fact`; result = await axios.get(catFactUrl); return result.data; } catch (err) { logger.error("Failed to call out to Cat Facts", {"error.message": err.message}); throw err; }};
如需了解更多信息,请查看如何与其他 Unity 服务集成