File tree Expand file tree Collapse file tree 2 files changed +5
-14
lines changed
examples/javascript/src/lib Expand file tree Collapse file tree 2 files changed +5
-14
lines changed Original file line number Diff line number Diff line change @@ -7,13 +7,14 @@ const defaultHost = "https://api.iheartjane.com"
77const authenticateClient = async ( ) => {
88 const clientId = process . env . JANE_CLIENT_ID || ''
99 const clientSecret = process . env . JANE_CLIENT_SECRET || ''
10- const apiUrl = process . env . JANE_API_URL
10+ const apiUrl = process . env . JANE_API_URL || defaultHost
1111
1212 const resp = await request ( {
1313 method : 'post' ,
1414 url : `${ apiUrl } /oauth/token` ,
15- grant_type : 'client_credentials'
16- } , {
15+ data : {
16+ grant_type : 'client_credentials' ,
17+ } ,
1718 auth : {
1819 username : clientId ,
1920 password : clientSecret
@@ -24,7 +25,7 @@ const authenticateClient = async () => {
2425}
2526
2627const makeRequest = async ( options ) => {
27- const apiUrl = process . env . JANE_API_URL
28+ const apiUrl = process . env . JANE_API_URL || defaultHost
2829
2930 if ( ! apiUrl ) {
3031 throw Error ( 'No JANE_API_URL configured' )
Original file line number Diff line number Diff line change @@ -16,16 +16,6 @@ describe('api service', () => {
1616 )
1717 } )
1818
19- describe ( 'if no JANE_API_URL is set' , ( ) => {
20- test ( 'it throws an error' , async ( ) => {
21- const token = 'someToken'
22-
23- await expect ( async ( ) => {
24- await apiService . post ( '/api/path' , { } , token )
25- } ) . rejects . toEqual ( new Error ( 'No JANE_API_URL configured' ) )
26- } )
27- } )
28-
2919 describe ( '#get' , ( ) => {
3020 beforeEach ( ( ) => {
3121 process . env . JANE_API_URL = 'https://test.localhost'
You can’t perform that action at this time.
0 commit comments