File tree Expand file tree Collapse file tree 8 files changed +64
-62
lines changed Expand file tree Collapse file tree 8 files changed +64
-62
lines changed Original file line number Diff line number Diff line change 1
- const axios = require ( ' axios' ) ;
2
- const xml2js = require ( "xml2js" ) ;
1
+ const axios = require ( " axios" ) ;
2
+ const xml2js = require ( "xml2js" ) ;
3
3
4
4
exports . handler = async ( event , context , callback ) => {
5
- const mediumURL = "https://medium.com/feed/codeuino" ;
6
- try {
7
- const response = await axios . get ( `${ mediumURL } ` ) ;
8
- const data = response . data ;
9
- xml2js . parseString ( data , ( err , result ) => {
10
- const sendthis = result . rss . channel [ 0 ] . item . slice ( 0 , 3 )
11
- callback ( null , {
12
- statusCode : 200 ,
13
- headers : {
14
- ' Access-Control-Allow-Origin' : '*'
15
- } ,
16
- body : JSON . stringify ( sendthis )
17
- } )
18
- } ) ;
19
- } catch ( err ) {
20
- console . log ( err ) ;
21
- }
22
- }
5
+ const mediumURL = "https://medium.com/feed/codeuino" ;
6
+ try {
7
+ const response = await axios . get ( `${ mediumURL } ` ) ;
8
+ const data = response . data ;
9
+ xml2js . parseString ( data , ( err , result ) => {
10
+ const sendthis = result . rss . channel [ 0 ] . item . slice ( 0 , 3 ) ;
11
+ callback ( null , {
12
+ statusCode : 200 ,
13
+ headers : {
14
+ " Access-Control-Allow-Origin" : "*"
15
+ } ,
16
+ body : JSON . stringify ( sendthis )
17
+ } ) ;
18
+ } ) ;
19
+ } catch ( err ) {
20
+ console . log ( err ) ;
21
+ }
22
+ } ;
Original file line number Diff line number Diff line change 1
- const axios = require ( "axios " ) ;
1
+ const TwitterAxios = require ( "../src/helpers/twitterAxios " ) ;
2
2
3
3
exports . handler = async ( event , context , callback ) => {
4
4
try {
5
- const TwitterApi = axios . create ( {
6
- baseURL : "https://api.twitter.com/1.1" ,
7
- headers : {
8
- Authorization :
9
- "Bearer AAAAAAAAAAAAAAAAAAAAAEtZGgEAAAAAToMHBHPR1ZpRPIVmo0B9G4syUxs%3DKJpStKohUbcPsI69bLsBOUbwrvpEpDL2JBJ9JuzvnkGDaMZ1Np"
10
- }
11
- } ) ;
12
-
13
- const likedTweetsResponse = await TwitterApi . get (
5
+ const likedTweetsResponse = await TwitterAxios . get (
14
6
"/favorites/list.json?count=50&screen_name=codeuino"
15
7
) ;
16
8
Original file line number Diff line number Diff line change 1
- const axios = require ( "axios " ) ;
1
+ const TwitterAxios = require ( "../src/helpers/twitterAxios " ) ;
2
2
3
3
exports . handler = async ( event , context , callback ) => {
4
4
try {
5
- const TwitterApi = axios . create ( {
6
- baseURL : "https://api.twitter.com/1.1" ,
7
- headers : {
8
- Authorization :
9
- "Bearer AAAAAAAAAAAAAAAAAAAAAEtZGgEAAAAAToMHBHPR1ZpRPIVmo0B9G4syUxs%3DKJpStKohUbcPsI69bLsBOUbwrvpEpDL2JBJ9JuzvnkGDaMZ1Np"
10
- }
11
- } ) ;
12
-
13
- const allTweetsResponse = await TwitterApi . get (
5
+ const allTweetsResponse = await TwitterAxios . get (
14
6
"/statuses/user_timeline.json?screen_name=codeuino&count=100"
15
7
) ;
16
8
Original file line number Diff line number Diff line change 1
1
[ build ]
2
2
functions = " lambda"
3
+
4
+ # provide twitter api key
5
+ [build .environment ]
6
+ TWITTER_API_KEY = " AAAAAAAAAAAAAAAAAAAAAEtZGgEAAAAAToMHBHPR1ZpRPIVmo0B9G4syUxs%3DKJpStKohUbcPsI69bLsBOUbwrvpEpDL2JBJ9JuzvnkGDaMZ1Np"
Original file line number Diff line number Diff line change 1
1
import React from "react" ;
2
2
import axios from "axios" ;
3
3
import "./Medium.css" ;
4
+ import base from "../../helpers/apiBase" ;
4
5
5
6
class Medium extends React . Component {
6
7
state = {
7
8
posts : [ ]
8
9
} ;
9
10
10
11
componentDidMount ( ) {
11
- const devUrl = 'http://localhost:9000/getBlogs' ;
12
- const prodUrl = '/.netlify/functions/getBlogs' ;
13
12
axios
14
- . get ( process . env . NODE_ENV === "development" ? devUrl : prodUrl )
13
+ . get ( base + "/getBlogs" )
15
14
. then ( res => {
16
15
const data = res . data ;
17
16
console . log ( data ) ;
18
17
this . setState ( {
19
- posts : data
18
+ posts : data
20
19
} ) ;
21
20
} ) ;
22
21
}
@@ -38,9 +37,7 @@ class Medium extends React.Component {
38
37
} }
39
38
> </ div >
40
39
< div className = "fading-box" >
41
- < div className = "view-more" >
42
- View More
43
- </ div >
40
+ < div className = "view-more" > View More</ div >
44
41
</ div >
45
42
</ a >
46
43
</ div >
Original file line number Diff line number Diff line change 1
- # myNav {
2
- background-color : white;
1
+ # myNav {
2
+ background-color : white;
3
3
}
4
4
5
5
.nav-item {
6
- margin-left : 10px ;
6
+ margin-left : 10px ;
7
7
}
8
8
9
9
.navbar-scroll {
10
- box-shadow : 0px 2px 15px grey;
10
+ box-shadow : 0px 2px 15px grey;
11
11
}
12
12
13
13
a {
14
- transition : transform 0.6s ;
14
+ transition : transform 0.6s ;
15
15
}
16
16
17
- a : hover {
18
- text-decoration : none;
19
- transform : scale (1.05 );
17
+ a : hover {
18
+ text-decoration : none;
19
+ transform : scale (1.05 );
20
20
}
21
21
22
- .nav-link : visited {
23
- color : rgba (0 , 0 , 0 , 0.7 );
22
+ .nav-link : visited {
23
+ color : rgba (0 , 0 , 0 , 0.7 );
24
24
}
25
25
26
- .nav-link .active , .nav-link .disabled , .nav-link : focus , .nav-link {
27
- color : rgba (0 , 0 , 0 , 0.7 ) !important ;
26
+ .nav-link .active ,
27
+ .nav-link .disabled ,
28
+ .nav-link : focus ,
29
+ .nav-link {
30
+ color : rgba (0 , 0 , 0 , 0.7 ) !important ;
28
31
}
29
32
30
- .blue : hover {
31
- color : lightblue;
32
- }
33
+ .blue : hover {
34
+ color : lightblue;
35
+ }
Original file line number Diff line number Diff line change
1
+ export default process . env . NODE_ENV === "development"
2
+ ? "http://localhost:9000"
3
+ : "/.netlify/functions" ;
Original file line number Diff line number Diff line change
1
+ const axios = require ( "axios" ) ;
2
+
3
+ const TwitterAxios = axios . create ( {
4
+ baseURL : "https://api.twitter.com/1.1" ,
5
+ headers : {
6
+ Authorization :
7
+ `Bearer ${ process . env . TWITTER_API_KEY } `
8
+ }
9
+ } ) ;
10
+
11
+ module . exports = TwitterAxios ;
You can’t perform that action at this time.
0 commit comments