• Basics
  • Abyss
  • Web APIs
  • C# & Razor
  • .net API
  • JS & TS API

    Show / Hide Table of Contents

    Class SxcGlobalHttp

    Global HTTP Service for information and helpers on $2sxc.http

    The $2sxc.http Api

    you are here (click to zoom) - discover the stack

    The $2sxc.http object contains information for doing custom API calls.

    Tip

    In most cases you won't use this, but instead get the Sxc object for the current instance and use either the data, query or webApi service.

    Internally this information is automatically retrieved from the html-header. The environment looks for a special meta-tag called _jsApi which contains all this information.

    Note

    Internally all these commands need the env to be ready. This means that the entire html <head> tag was processed by the browser. A very safe way to do this is to run your code on-document-ready, or just to ensure that whatever bootstraps your application runs inside the <body> tag.

    The http also has some internal methods which are not documented here.

    History

    1. Introduced in 2sxc 10.25

    Package: Api.Js.SxcJs

    Methods

    apiUrl(string)

    Convert short urls like app/auto/api/Posts/All to the full URL needed. Will ignore urls which clearly already are the full url.

    Declaration
    function apiUrl(url: string)
    Parameters
    Type Name Description
    string url

    short URL like app/auto/api/Posts/All

    Returns
    Type Description
    string

    the converted, long url with the full endpoint

    apiUrl(string, string)

    Convert short urls like app/auto/api/Posts/All to the full URL needed. Will ignore urls which clearly already are the full url.

    Declaration
    function apiUrl(url: string, endpointName: string)
    Parameters
    Type Name Description
    string url

    short URL like app/auto/api/Posts/All

    string endpointName

    optional endpoint name if accessing a different exotic endpoint

    Returns
    Type Description
    string

    the converted, long url with the full endpoint

    headers()

    All the headers which are needed in an ajax call.

    Declaration
    function headers()
    Returns
    Type Description
    Record<string, string>

    Dictionary / Record of headers

    headers(number)

    All the headers which are needed in an ajax call - within a module context.

    Declaration
    function headers(id: number)
    Parameters
    Type Name Description
    number id

    optional module ID

    Returns
    Type Description
    Record<string, string>

    Dictionary / Record of headers

    headers(number, number)

    All the headers which are needed in an ajax call - within a module and content-block context.

    Declaration
    function headers(id: number, cbid: number)
    Parameters
    Type Name Description
    number id

    optional module ID

    number cbid

    optional content block ID

    Returns
    Type Description
    Record<string, string>

    Dictionary / Record of headers

    headers(number, number, ContextIdentifier)

    All the headers which are needed in an ajax call. Uses a module and content-block context (but these could also be null) and a full context identifier for advanced operations.

    Declaration
    function headers(id: number, cbid: number, ctx: ContextIdentifier)
    Parameters
    Type Name Description
    number id

    optional module ID

    number cbid

    optional content block ID

    ContextIdentifier ctx

    optional context information to include in the header

    Returns
    Type Description
    Record<string, string>

    Dictionary / Record of headers

    • Improve this Doc
    Back to top Generated by DocFX