1
- import axios from " axios"
2
- import fetchData from " ./fetch"
3
- import { Node } from " ./nodes"
4
- import { capitalize } from " lodash"
1
+ import axios from ' axios'
2
+ import fetchData from ' ./fetch'
3
+ import { Node } from ' ./nodes'
4
+ import { capitalize } from ' lodash'
5
5
6
6
exports . sourceNodes = async (
7
7
{ boundActionCreators } ,
8
- { apiURL = " http://localhost:1337" , contentTypes = [ ] , loginData = { } }
8
+ { apiURL = ' http://localhost:1337' , contentTypes = [ ] , loginData = { } }
9
9
) => {
10
10
const { createNode } = boundActionCreators
11
11
let jwtToken = null
12
12
13
13
// Check if loginData is set.
14
14
if (
15
- loginData . hasOwnProperty ( " identifier" ) &&
15
+ loginData . hasOwnProperty ( ' identifier' ) &&
16
16
loginData . identifier . length !== 0 &&
17
- loginData . hasOwnProperty ( " password" ) &&
17
+ loginData . hasOwnProperty ( ' password' ) &&
18
18
loginData . password . length !== 0
19
19
) {
20
- console . time ( " Authenticate Strapi user" )
21
- console . log ( " Authenticate Strapi user" )
20
+ console . time ( ' Authenticate Strapi user' )
21
+ console . log ( ' Authenticate Strapi user' )
22
22
23
23
// Define API endpoint.
24
24
const loginEndpoint = `${ apiURL } /auth/local`
@@ -27,14 +27,14 @@ exports.sourceNodes = async (
27
27
try {
28
28
const loginResponse = await axios . post ( loginEndpoint , loginData )
29
29
30
- if ( loginResponse . hasOwnProperty ( " data" ) ) {
30
+ if ( loginResponse . hasOwnProperty ( ' data' ) ) {
31
31
jwtToken = loginResponse . data . jwt
32
32
}
33
33
} catch ( e ) {
34
- console . error ( " Strapi authentication error: " + e )
34
+ console . error ( ' Strapi authentication error: ' + e )
35
35
}
36
36
37
- console . timeEnd ( " Authenticate Strapi user" )
37
+ console . timeEnd ( ' Authenticate Strapi user' )
38
38
}
39
39
40
40
// Generate a list of promises based on the `contentTypes` option.
0 commit comments