FCF 2.0 development in progress...
> > > >
[News] [Packages API] [Downloads] [Donate to the project] [Contacts]

fcf.load() function

fcf.Actions->mixed fcf.load(string a_uri)
fcf.Actions->mixed fcf.load(string a_uri, object a_options)

Package: fcf-framework-core

File: fcf-framework-core:fcf.js

Available from version: 2.0.2

Loads a resource (file or HTTP/HTTPS) at the given URI.


string a_uri
- Resource URI or file path on a server

object a_options
- Additional options
  • string|object|FormData body - Data sent in the HTTP/HTTPS request body. The request body can be a FormData object, but only for browser-side requests.

  • string method = "GET" - HTTP/HTTPS request method ("GET", "POST", etc.)

  • boolean|"auto" external = false - By default, if the function is executed on the server side, it downloads only files located on the server side, and if you need to execute an http request, you need to set the parameter to true or "auto". The external parameter can take the following values:

    • false - Server side resource loading is done, only for local files

    • true - The resource is loaded on the server side, only via HTTP/HTTPS protocols

    • "auto" - Server-side resource loading is performed for both local files and HTTP/HTTPS resources

  • bool async = true - If equals true. The method is executed asynchronously. If it is false, then the method is executed synchronously, but for HTTP/HTTPS, synchronous mode works only on the browser side.

  • object header - An object with HTTP/HTTPS request header properties.

  • string format - Response data format (raw|json|auto)

    • "raw" - The function returns the received string containing the resource data

    • "json" - The function returns a JS object received as JSON resource data

    • "auto" - The function returns a JS object or string. If the resource returned data in JSON format, the function will return a JS object, if the data cannot be read as JSON, then the function will return a string

- Returns a deferred action object containing the result of the request or with the contents of a file

Example: Function application

{ let result = await fcf.load("fcf-framework-core:package.json"); console.log(result); }


{ "name": "fcf-framework-core", ...