Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spotify api feature #5

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 25 additions & 30 deletions monster/client/src/MusicMonster.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,29 @@ class MusicMonster extends Component {
username: "",
password: "",
home: true,
testObject: {},
};
this.submitToServer = this.submitToServer.bind(this);
this.handleInputChange = this.handleInputChange.bind(this);
this.handleUsernameInput = this.handleUsernameInput.bind(this);
this.handlePasswordInput = this.handlePasswordInput.bind(this);
this.callSpotifyApi = this.callSpotifyApi.bind(this);
this.checkUrl = this.checkUrl.bind(this);
}

componentWillMount() {
console.log("Will Mount...");
};

<<<<<<< HEAD
componentDidMount() {
console.log('Did mount...');
=======
componentDidMount(e) {
console.log("HAAAAAAAAAA");
this.checkUrl();

console.log("Did mount...");
>>>>>>> f76406d5617f33a8ed8ca3785342672b40b1b51c
this.checkUrl();
}
componentWillMount() {
console.log("Will Mount...");
axios('http://localhost:3001/api/results')
.then(res => {
this.setState(prevState => {
return {
testObject: res,
}
});
});
};

handleInputChange(event) {
Expand All @@ -65,7 +65,7 @@ class MusicMonster extends Component {
});
console.log(event.target.value);
// console.log(this.state.input);
};
}

checkUrl() {
console.log("CheckingURL -------->", this.state.home);
Expand Down Expand Up @@ -118,7 +118,7 @@ class MusicMonster extends Component {
searchData: res.data.artists.items,
artist: artistName,
image: image,
track: "https://open.spotify.com/embed?uri=" + track_url
song: "https://open.spotify.com/embed?uri=" + track_url
});
console.log("Track URL", this.state.track);
})
Expand All @@ -131,24 +131,24 @@ class MusicMonster extends Component {

axios({
method: "POST",
url: "http://localhost:3001/api/user/",
url: "http://localhost:3001/api/results/",
data: {
name: this.state.artist,
picture: this.state.image,
track: this.state.track,
}

artist: this.state.artist,
image: this.state.image,
song: this.state.image,
},
})
.then(res => {
console.log(this.state.artist, "-----------");
// res will include all the information you sent back from the server
const savingMusicToDataBase = {
name: res.data.artists.items["0"].name,
picture: res.data.artists.items["0"].images[1].url,
artist: res.data.artists.items["0"].name,
image: res.data.artists.items["0"].images[1].url,
song: res.data.artists.items["0"].external_urls.spotify
};
this.setState(prevState => {
return {
artists: prevState.artists.concat(savingMusicToDataBase),
artist: prevState.artists.concat(savingMusicToDataBase.artist),
};
});
})
Expand Down Expand Up @@ -223,7 +223,7 @@ class MusicMonster extends Component {
checkUrl={this.checkUrl}
artist={this.state.artist}
image={this.state.image}
track={this.state.track}
song={this.state.song}
data={this.state.searchData}
input={this.state.input}
/>
Expand All @@ -236,12 +236,7 @@ class MusicMonster extends Component {
<Footer />
</main>
</div>
<<<<<<< HEAD
);
=======
)
>>>>>>> f76406d5617f33a8ed8ca3785342672b40b1b51c
}
}

export default MusicMonster;
2 changes: 1 addition & 1 deletion monster/client/src/components/Results.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Results extends Component {
<img src={this.props.image} alt={this.props.artist} />
</div>
<div className="tracks">
<iframe src={this.props.track} width="400" height="415" />
<iframe src={this.props.song} width="400" height="415" />
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion monster/db/migrations/migration.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ CREATE TABLE records (
artist VARCHAR(255) NOT NULL,
image TEXT,
song VARCHAR(255) NOT NULL,
comments TEXT DEFAULT "favorite track"
comments TEXT
);

78 changes: 39 additions & 39 deletions monster/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions monster/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"express-jwt": "^5.3.0",
"express-session": "^1.15.5",
"json-web-token": "^2.1.3",
"jsonwebtoken": "^8.0.1",
"morgan": "^1.8.2",
"nodemon": "^1.12.1",
"passport": "^0.4.0",
Expand Down