diff --git a/package.json b/package.json index 9c34734..550bb47 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "private": true, "dependencies": { "antd": "^3.10.1", + "axios": "^0.18.0", "babel-plugin-import": "^1.9.1", "react": "^16.5.2", "react-app-rewired": "^1.6.2", diff --git a/src/Map/Screen.js b/src/Map/Screen.js index 2e6af26..acb7c31 100644 --- a/src/Map/Screen.js +++ b/src/Map/Screen.js @@ -5,6 +5,7 @@ import "./Screen.css"; import { MapLocation } from "./Location"; import { LocationModal } from "./LocationModal"; import { Marker } from "react-google-maps"; +import { fireBaseInstance } from "../axios"; const mockData = [ { id: 0, @@ -129,6 +130,13 @@ class MapScreen extends React.Component { loadMockData = () => { this.setState({ data: mockData }); }; + postToFirebase = () => { + const { data } = this.state; + fireBaseInstance + .post("/fbData.json", data) + .then(response => console.log(response)) + .catch(error => console.log(error)); + }; render() { // console.log(this.state.data); @@ -177,6 +185,13 @@ class MapScreen extends React.Component { + diff --git a/src/axios.js b/src/axios.js new file mode 100644 index 0000000..8e596d0 --- /dev/null +++ b/src/axios.js @@ -0,0 +1,8 @@ +import axios from "axios"; + +// Firebase instance +export const fireBaseInstance = axios.create({ + baseURL: "https://react-map-app-f2045.firebaseio.com/" +}); + +fireBaseInstance.defaults.headers.post["Content-Type"] = "application/json"; diff --git a/yarn.lock b/yarn.lock index a32fde7..ccae259 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1488,6 +1488,13 @@ aws4@^1.8.0: version "1.8.0" resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.8.0.tgz#f0e003d9ca9e7f59c7a508945d7b2ef9a04a542f" +axios@^0.18.0: + version "0.18.0" + resolved "http://registry.npmjs.org/axios/-/axios-0.18.0.tgz#32d53e4851efdc0a11993b6cd000789d70c05102" + dependencies: + follow-redirects "^1.3.0" + is-buffer "^1.1.5" + axobject-query@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-2.0.1.tgz#05dfa705ada8ad9db993fa6896f22d395b0b0a07" @@ -4096,7 +4103,7 @@ flush-write-stream@^1.0.0: inherits "^2.0.1" readable-stream "^2.0.4" -follow-redirects@^1.0.0: +follow-redirects@^1.0.0, follow-redirects@^1.3.0: version "1.5.9" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.9.tgz#c9ed9d748b814a39535716e531b9196a845d89c6" dependencies: