This repository has been archived by the owner on May 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
116 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
REACT_APP_API_HOST_URL=http://192.168.55.55:4000/api |
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 |
---|---|---|
|
@@ -20,4 +20,5 @@ npm-debug.log* | |
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
.env | ||
server |
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,38 @@ | ||
import fetch from 'isomorphic-fetch'; | ||
|
||
const API_HOST = process.env.REACT_APP_API_HOST_URL; | ||
|
||
function headers() { | ||
return { | ||
Accept: 'application/json', | ||
'Content-Type': 'application/json', | ||
}; | ||
} | ||
|
||
function parseResponse(response) { | ||
return response.json().then((json) => { | ||
if (!response.ok) { | ||
return Promise.reject(json); | ||
} | ||
return json; | ||
}); | ||
} | ||
|
||
function queryString(params) { | ||
const query = Object.keys(params) | ||
.map((k) => `${encodeURIComponent(k)}=${encodeURIComponent(params[k])}`) | ||
.join('&'); | ||
return `${query.length ? '?' : ''}${query}`; | ||
} | ||
|
||
const API = { | ||
fetch(url, params = {}) { | ||
return fetch(`${API_HOST}${url}${queryString(params)}`, { | ||
method: 'GET', | ||
headers: headers(), | ||
}) | ||
.then(parseResponse); | ||
}, | ||
} | ||
|
||
export default API; |
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,6 @@ | ||
export const OVER_IN_NOTE = 'OVER_IN_NOTE'; | ||
export const OVER_IN_NOTE = 'OVER_IN_NOTE'; | ||
export const OVER_OUT_NOTE = 'OVER_OUT_NOTE'; | ||
export const SELECT_NOTE = 'SELECT_NOTE'; | ||
export const NEW_NOTE = 'NEW_NOTE'; | ||
export const SELECT_NOTE = 'SELECT_NOTE'; | ||
export const NEW_NOTE = 'NEW_NOTE'; | ||
export const REQUEST_NOTES = 'REQUEST_NOTES'; | ||
export const RECEIVE_NOTES = 'RECEIVE_NOTES'; |
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 |
---|---|---|
|
@@ -2056,7 +2056,7 @@ dot-prop@^3.0.0: | |
dependencies: | ||
is-obj "^1.0.0" | ||
|
||
[email protected]: | ||
[email protected], dotenv@^4.0.0: | ||
version "4.0.0" | ||
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-4.0.0.tgz#864ef1379aced55ce6f95debecdce179f7a0cd1d" | ||
|
||
|