Skip to content

Commit

Permalink
slack location bot !
Browse files Browse the repository at this point in the history
  • Loading branch information
sharathvignesh committed Feb 24, 2017
1 parent c79cdbc commit 24fdeb0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
26 changes: 25 additions & 1 deletion reactJS/app/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import getMuiTheme from 'material-ui/styles/getMuiTheme';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import Footer from './Footer.js';
import Header from './Header';

var $ = require ('jquery');
let styles = {
robotofont: {
fontFamily: 'sans-serif'
Expand All @@ -23,6 +23,30 @@ const muiTheme = getMuiTheme({


class App extends Component {
componentDidMount(){
console.log("did mount");
$.get("https://ipinfo.io", function(response) {
const city = response.city;
fetch('https://hooks.slack.com/services/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', {
credentials: 'omit',
method: 'POST',
//body: JSON.stringify({'value' : value})})
body: JSON.stringify({'text' : "Cheers ! someone viewed our App from " + city})})
.then(res => {
if (res.status !== 200) {
let status = res.status;
console.log('error in posting event');
}
console.log("succesfully saved");
console.log(res.json());
})
.then(res =>{
console.log(res);
})
}, "jsonp")

}

render() {
return (
<MuiThemeProvider muiTheme={muiTheme}>
Expand Down
1 change: 1 addition & 0 deletions reactJS/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"graphql-tag": "^0.1.15",
"isomorphic-fetch": "^2.2.1",
"jade": "^1.11.0",
"jquery": "^3.1.1",
"json-loader": "^0.5.4",
"less-middleware": "^2.1.0",
"material-ui": "^0.16.7",
Expand Down

0 comments on commit 24fdeb0

Please sign in to comment.