Playing around with youtube api and reactjs
I am calling youtube api. Recently noticed there is create in axios so I wanted to use it but somehow params kept on overwritten
What am I doing wrong here?
I have a file named youtube.api
import axios from 'axios';
export default axios.create({
baseURL: 'https://www.googleapis.com/youtube/v3',
params: {
part: 'snippet',
key: 'blahkey',
}
});
then inside my react handleOnSubmit
import youtube from '../apis/youtube';
handleOnSubmit = async (e) => {
e.preventDefault();
console.log(this.state.query);
const response = await youtube.get('/search', {
params: { q: this.state.query }
});
console.log(response, 'response');
};
console.log(response, 'response');
I get an error of https://www.googleapis.com/youtube/v3/search?q=book 400
the params of part and key are missing from the url though.
Can someone please give me a hand?
Thanks in advance