viralvideos
viralvideos copied to clipboard
postman test before programming
Dear Florian,
Thanks for your yt API video, I wrote the react app but I got error 400 In console, I tried this GET request in postman but same problem. I checked my key according to your video. would you guide me for correct Http request 👍 ?
https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=UUbW18JZRgko_mOGm5er8Yzg&key=[AIzaSyBwmR5TEYmX-AWfE-PUQBo3F2ykXmcckuU]
my react component :
import React, { Component } from 'react';
import axios from 'axios';
export default class YouTube extends Component {
constructor(props) {
super(props);
this.state = {video: []};
}
componentWillMount() {
setInterval(() => {
this.VideoList();
}, 2000)
}
VideoList() {
axios.get('https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=UUbW18JZRgko_mOGm5er8Yzg&key={AIzaSyDmewDxM6y0FCqY8z_2mx5iIkMs5y20Y0I')
.then((response) => {
this.setState({video: response.data.items});
})
.catch(function (error) {
console.log(error);
});
}
render() {
return (
<div id="layout-content" className="layout-content-wrapper">
<div className="panel-list">
{
this.state.video.map((item, i) =>{
return(
<h1 key={i}>{item.items}</h1>
)
})
//this.state.video.map((item, i) => {return( <h1 key={i}>{item.snippet.title}<h1>)
}
</div>
</div>
)
}
}
Hey @Farbod29, thanks for stopping by this repo.
I remember trying to use the API in a React project loading the googleapis npm module a couple years back with no success due to some sort of conflict with the framework. So maybe that would work well now?
However you could just load the same external script to do the same, (https://apis.google.com/js/client.js). I guess you could hit the Rest API directly, I've never done it outside of their sandbox. I'd recommend using an existing JS client anyway.
Florian
Hey Florian @FriesFlorian, thanks for your response I try tonight after work and update here :)
HI I have cloned this repo and used as it is....created my secret key for youtube api and enabled it....but when i am doing search from index.html (front end) not able to see any results... I have not done any changes apart from changing the key....what should I do?