Skip to content

Commit 3e0316f

Browse files
committed
dot env added
1 parent 20cbcc0 commit 3e0316f

11 files changed

+12850
-7
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
.env.development.local
1818
.env.test.local
1919
.env.production.local
20+
.env
2021

2122
npm-debug.log*
2223
yarn-debug.log*

package-lock.json

+12,722
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"private": true,
55
"dependencies": {
66
"axios": "^0.18.0",
7+
"dotenv": "^8.0.0",
78
"express": "^4.17.0",
89
"nodemon": "^1.19.0",
910
"path": "^0.12.7",
@@ -17,7 +18,7 @@
1718
"test": "react-scripts test",
1819
"eject": "react-scripts eject",
1920
"server": "nodemon server.js",
20-
"start":"node server.js"
21+
"start": "node server.js"
2122
},
2223
"eslintConfig": {
2324
"extends": "react-app"

public/index.html

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
1111
-->
1212
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
13+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.0/animate.min.css">
14+
1315
<!--
1416
Notice the use of %PUBLIC_URL% in the tags above.
1517
It will be replaced with the URL of the `public` folder during the build.

src/App.css

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
height: 40vmin;
88
pointer-events: none;
99
}
10+
.App-logo-small {
11+
animation: App-logo-spin infinite 20s linear;
12+
height: 20vmin;
13+
pointer-events: none;
14+
}
1015

1116
.App-header {
1217
background-color: #282c34;

src/App.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
import React from 'react';
22
import logo from './logo.svg';
33
import ChucksJoke from './ChucksJoke'
4+
import Quote from './Quote'
5+
import SkyScanner from './SkyScanner'
6+
import Chuck from './assets/chuck.jpg'
47
import './App.css';
58

9+
610
function App() {
711
return (
812
<div className="App">
913
<header className="App-header">
1014
<img src={logo} className="App-logo" alt="logo" />
15+
<Quote />
16+
<img src={Chuck} className="animated fadeInLeftBig delay-2s" alt="cuck" />
1117
<ChucksJoke />
12-
<p>
13-
Edit <code>src/App.js</code> and save to reload.
14-
</p>
18+
<img src={logo} className="App-logo-small" alt="logo" />
19+
<SkyScanner />
1520
<a
1621
className="App-link"
1722
href="https://reactjs.org"
1823
target="_blank"
1924
rel="noopener noreferrer"
2025
>
21-
Team Cobra gogogogogo!!!
26+
Team Cobra - Saviours of the Universe!!!
2227
</a>
2328
</header>
2429
</div>

src/ChucksJoke.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React from "react";
2+
require('dotenv').config()
23

3-
export default class ApiOne extends React.Component {
4+
5+
export default class ChucksJoke extends React.Component {
46
constructor() {
57
super();
68
this.state = {
@@ -16,7 +18,8 @@ export default class ApiOne extends React.Component {
1618
);
1719
myHeaders.append(
1820
"X-RapidAPI-Key",
19-
"5456615b4cmsh40eaeb350692ccep17bbe1jsn2758aaa3f720"
21+
22+
process.env.REACT_APP_API_RAPID
2023
);
2124
myHeaders.append("accept", "application/json");
2225

src/Quote.js

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import React from "react";
2+
require('dotenv').config()
3+
console.log(process.env)
4+
5+
6+
export default class Quote extends React.Component {
7+
constructor() {
8+
super();
9+
this.state = {
10+
quote: []
11+
};
12+
}
13+
14+
componentDidMount() {
15+
const myHeadersOne = new Headers();
16+
myHeadersOne.append(
17+
"X-RapidAPI-Host", "andruxnet-random-famous-quotes.p.rapidapi.com"
18+
);
19+
myHeadersOne.append(
20+
"X-RapidAPI-Key", process.env.REACT_APP_API_RAPID
21+
);
22+
23+
const myInit = { method: "GET", headers: myHeadersOne };
24+
25+
const myRequestOne = new Request(
26+
"https://andruxnet-random-famous-quotes.p.rapidapi.com/?cat=famous&count=1",
27+
myInit
28+
);
29+
30+
fetch(myRequestOne)
31+
.then(res => res.json())
32+
.then(data =>
33+
this.setState({
34+
quote: data[0].quote
35+
})
36+
);
37+
}
38+
39+
render() {
40+
return (
41+
<div className="container">
42+
<h2>{this.state.quote}</h2>
43+
</div>
44+
);
45+
}
46+
}

src/SkyScanner.js

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import React from "react";
2+
require('dotenv').config()
3+
4+
5+
export default class SkyScanner extends React.Component {
6+
constructor() {
7+
super();
8+
this.state = {
9+
minPrice: [],
10+
departure: '',
11+
arrival: ''
12+
};
13+
}
14+
15+
componentDidMount() {
16+
const myHeadersOne = new Headers();
17+
myHeadersOne.append(
18+
"X-RapidAPI-Host", "skyscanner-skyscanner-flight-search-v1.p.rapidapi.com"
19+
);
20+
myHeadersOne.append(
21+
"X-RapidAPI-Key", process.env.REACT_APP_API_RAPID
22+
);
23+
24+
const myInit = { method: "GET", headers: myHeadersOne };
25+
26+
const myRequestOne = new Request(
27+
"https://skyscanner-skyscanner-flight-search-v1.p.rapidapi.com/apiservices/browsequotes/v1.0/US/USD/en-US/SFO-sky/JFK-sky/2019-10-01?inboundpartialdate=2019-09-01",
28+
myInit
29+
);
30+
31+
fetch(myRequestOne)
32+
.then(res => res.json())
33+
.then(data =>
34+
this.setState({
35+
minPrice: data.Quotes[0].MinPrice,
36+
departure: data.Places[0].Name,
37+
arrival: data.Places[1].Name
38+
})
39+
);
40+
41+
}
42+
43+
render() {
44+
return (
45+
<div className="container">
46+
47+
<h2>{this.state.departure} to {this.state.arrival}- £{this.state.minPrice}</h2>
48+
</div>
49+
);
50+
}
51+
}
52+
53+

src/assets/chuck.jpg

40 KB
Loading

yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -3475,6 +3475,11 @@ dotenv@6.2.0:
34753475
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-6.2.0.tgz#941c0410535d942c8becf28d3f357dbd9d476064"
34763476
integrity sha512-HygQCKUBSFl8wKQZBSemMywRWcEDNidvNbjGVyZu3nbZ8qq9ubiPoGLMdRDpfSrpkkm9BXYFkpKxxFX38o/76w==
34773477

3478+
dotenv@^8.0.0:
3479+
version "8.0.0"
3480+
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.0.0.tgz#ed310c165b4e8a97bb745b0a9d99c31bda566440"
3481+
integrity sha512-30xVGqjLjiUOArT4+M5q9sYdvuR4riM6yK9wMcas9Vbp6zZa+ocC9dp6QoftuhTPhFAiLK/0C5Ni2nou/Bk8lg==
3482+
34783483
duplexer3@^0.1.4:
34793484
version "0.1.4"
34803485
resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2"

0 commit comments

Comments
 (0)