-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Typeform/refactor-http-transport
Refactor http transport
- Loading branch information
Showing
25 changed files
with
1,187 additions
and
407 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,28 @@ | ||
import axios from 'axios' | ||
import 'isomorphic-fetch' | ||
import { API_BASE_URL } from './constants' | ||
|
||
export const clientConstructor = ({ token, ...options }) => { | ||
return axios.create({ | ||
baseURL: 'https://api.typeform.com', | ||
headers: { | ||
Authorization: `bearer ${token}` | ||
}, | ||
...options | ||
}) | ||
return { | ||
request: (args) => { | ||
|
||
const { | ||
url, | ||
...otherArgs | ||
} = args | ||
|
||
const requestParameters = { | ||
...options, | ||
...otherArgs | ||
} | ||
|
||
return fetch(`${API_BASE_URL}${url}`, { | ||
headers: { | ||
Authorization: `bearer ${token}` | ||
}, | ||
...requestParameters | ||
}) | ||
.then(response => response.json()) | ||
// .catch(error => { throw `${error}` }) | ||
} | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export const responses = http => ({ | ||
export default http => ({ | ||
list: args => getResponses(http, args) | ||
}) | ||
|
||
|
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"forms": [ | ||
{ | ||
"id": "abc123", | ||
"title": "test form", | ||
"fields": [] | ||
}, | ||
{ | ||
"id": "xyz123", | ||
"title": "test form 2", | ||
"fields": [] | ||
} | ||
] | ||
} |
Oops, something went wrong.