Created
December 14, 2017 20:44
-
-
Save dantenovski/b93c8f6561e41ae51579a25516dc2199 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var token = localStorage.getItem('my_tkn'); | |
var httpHeaders; | |
//'x-access-token': token | |
//'Authorization' : token | |
if(token){ | |
httpHeaders = { | |
'Content-Type' : 'application/x-www-form-urlencoded', | |
'Accept' : 'application/json', | |
'x-access-token' : token | |
}; | |
} else { | |
httpHeaders = { | |
'Content-Type' : 'application/x-www-form-urlencoded', | |
'Accept' : 'application/json' | |
}; | |
} | |
/* | |
httpHeaders = { | |
'Content-Type' : 'application/x-www-form-urlencoded', | |
'Accept' : 'application/json' | |
}; | |
*/ | |
let options = { | |
method: 'post', | |
body: urlEncodedData // login and password | |
}; | |
options.headers = new Headers(httpHeaders); | |
const response = yield call(fetch, `http://mysite.com/${path}`, options); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This way the server rejects the HTTP request as malformed. But when I do just like this
it works just fine