2.0.1 • Published 2 years ago

@shopify/csrf-token-fetcher v2.0.1

Weekly downloads
8,306
License
MIT
Repository
github
Last release
2 years ago

@shopify/csrf-token-fetcher

Build Status Build Status License: MIT npm version npm bundle size (minified + gzip)

JavaScript utility function to fetch the CSRF token required to make requests to a Rails server.

Installation

$ yarn add @shopify/csrf-token-fetcher

API Reference

function getCSRFToken(scope = document)

Retrieve the CSRF token from the meta tag rendered by a Rails server. This token is required in the X-CSRF-Token header for requests to the Rails server.

In the html.erb file:

<%= csrf_meta_tags %>

Example Usage

import getCSRFToken from '@shopify/csrf-token-fetcher';

getCSRFToken();
// → 'token_value'
2.0.1

2 years ago

2.0.0

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.1

6 years ago