0
0
Fork 0
mirror of https://github.com/VueTubeApp/VueTube synced 2024-11-01 01:12:39 +00:00
VueTube/NUXT/plugins/youtube.js
2022-03-02 08:14:52 -05:00

36 lines
817 B
JavaScript

//--- Modules/Imports ---//
import { Http } from '@capacitor-community/http';
//--- Logger Function ---//
function logger(func, data) {
module.logs.push({
name: func,
time: Date.now(),
data: data
})
}
const module = {
logs: new Array(),
//--- Get YouTube's Search Auto Complete ---//
async autoComplete(text, callback) {
const res = await Http.request({
method: 'GET',
url: 'https://suggestqueries-clients6.youtube.com/complete/search',
params: { client: 'youtube', q: text }
})
.catch((err) => {
logger("autoComplete", err);
callback(err);
});
logger("autoComplete", res);
callback(res);
}
}
//--- Start ---//
export default ({ app }, inject) => {
inject('youtube', module)
}
logger("Initialize","Program Started");