Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scratch-www
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
scratch-www
Commits
1205ed01
Commit
1205ed01
authored
Mar 18, 2016
by
Ray Schamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Api mixin usable as a standalone module
parent
faabc63e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
7 deletions
+1
-7
src/mixins/api.jsx
src/mixins/api.jsx
+1
-7
No files found.
src/mixins/api.jsx
View file @
1205ed01
...
@@ -4,8 +4,6 @@ var xhr = require('xhr');
...
@@ -4,8 +4,6 @@ var xhr = require('xhr');
var
jar
=
require
(
'
../lib/jar.js
'
);
var
jar
=
require
(
'
../lib/jar.js
'
);
var
log
=
require
(
'
../lib/log.js
'
);
var
log
=
require
(
'
../lib/log.js
'
);
var
CookieMixinFactory
=
require
(
'
./cookieMixinFactory.jsx
'
);
/**
/**
* Component mixin that constructs requests to the scratch api.
* Component mixin that constructs requests to the scratch api.
* Custom arguments:
* Custom arguments:
...
@@ -15,10 +13,6 @@ var CookieMixinFactory = require('./cookieMixinFactory.jsx');
...
@@ -15,10 +13,6 @@ var CookieMixinFactory = require('./cookieMixinFactory.jsx');
* It also takes in other arguments specified in the xhr library spec.
* It also takes in other arguments specified in the xhr library spec.
*/
*/
var
Api
=
{
var
Api
=
{
mixins
:
[
// Provides useScratchcsrftoken
CookieMixinFactory
(
'
scratchcsrftoken
'
,
'
/csrf_token/
'
)
],
api
:
function
(
opts
,
callback
)
{
api
:
function
(
opts
,
callback
)
{
defaults
(
opts
,
{
defaults
(
opts
,
{
host
:
window
.
env
.
API_HOST
,
host
:
window
.
env
.
API_HOST
,
...
@@ -57,7 +51,7 @@ var Api = {
...
@@ -57,7 +51,7 @@ var Api = {
opts
.
headers
[
'
Accept-Language
'
]
=
jar
.
get
(
'
scratchlanguage
'
)
+
'
, en;q=0.8
'
;
opts
.
headers
[
'
Accept-Language
'
]
=
jar
.
get
(
'
scratchlanguage
'
)
+
'
, en;q=0.8
'
;
}
}
if
(
opts
.
useCsrf
)
{
if
(
opts
.
useCsrf
)
{
this
.
useScratchcsrftoken
(
function
(
err
,
csrftoken
)
{
jar
.
use
(
'
scratchcsrftoken
'
,
'
/csrf_token/
'
,
function
(
err
,
csrftoken
)
{
if
(
err
)
return
log
.
error
(
'
Error while retrieving CSRF token
'
,
err
);
if
(
err
)
return
log
.
error
(
'
Error while retrieving CSRF token
'
,
err
);
opts
.
json
.
csrftoken
=
csrftoken
;
opts
.
json
.
csrftoken
=
csrftoken
;
opts
.
headers
[
'
X-CSRFToken
'
]
=
csrftoken
;
opts
.
headers
[
'
X-CSRFToken
'
]
=
csrftoken
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment