Skip to content

Feature: REST

ᴏᴠ ━ ᴀɴɪꜱᴀ edited this page Nov 10, 2024 · 10 revisions

━ What's the Objective?

Longing for more straightforward, simplistic and optimized version of fetchRemote & callRemote to increase your productivity? Switch to Assetify's REST module and let us manage it natively for you! 😃

━ How to Import?

Add the below code once in either of the shared .lua script of the resource you want to use within:

--Declare it globally only once
loadstring(exports.assetify_library:import("rest"))()

━ APIs

━ assetify.rest:get() (Shared)

@Objective: Executes a GET request on specified URL.
local promise: cPromise = assetify.rest:get(
  string: route, --Remote URL
  int: timeout --(Optional)
)

━ assetify.rest:post() (Shared)

@Objective: Executes a POST request on specified URL.
local promise: cPromise = assetify.rest:post(
  string: route, --Remote URL
  table: data,
  int: timeout --(Optional),
  table: credentials --(Optional) Essentially required for protected requests.
)