nmodule/js/rc/csrf/csrfUtil

An API to get the CSRF token.

Description:
  • An API to get the CSRF token.

Source:

Members

(static) CSRF_TOKEN_HEADER_KEY :string

Description:
  • Csrf token http header key name.

Source:

Csrf token http header key name.

Type:
  • string

Methods

(static) getCsrfToken() → {String}

Description:
  • Get the URI encoded form of the csrf token.

Source:
Example

Access the CSRF token and pass to AJAX as a header

define(["nmodule/js/rc/csrf/csrfUtil"], function(csrfUtil){
   var csrfToken = csrfUtil.getCsrfToken();
   var headers = {};
   headers[csrfUtil.CSRF_TOKEN_HEADER_KEY] = csrfToken;
   $.ajax("someURI", {
     method: "POST",
     data: "someContent",
     headers : headers
   });
});
Returns:

CSRF string (encoded)

Type
String