mirror of
https://github.com/Bigherollc/wticreatorstudio.git
synced 2026-01-16 19:05:08 -05:00
42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
import { toValue } from "vue";
|
|
import { toast } from "vue3-toastify";
|
|
import { request } from "@/helpers/axios";
|
|
|
|
export function useRestream() {
|
|
function updateRestreamSettings(clientId, clientSecret) {
|
|
return new Promise(async (resolve, reject) => {
|
|
try {
|
|
const response = await request().put(route("restream.update-settings"), {
|
|
client_id: toValue(clientId),
|
|
client_secret: toValue(clientSecret),
|
|
});
|
|
const { data } = response;
|
|
const { message, item } = data;
|
|
|
|
toast(message, {
|
|
type: toast.TYPE.SUCCESS,
|
|
position: toast.POSITION.TOP_RIGHT,
|
|
});
|
|
resolve(item);
|
|
} catch (error) {
|
|
handleError(error);
|
|
reject(error);
|
|
}
|
|
});
|
|
}
|
|
|
|
function handleError(error) {
|
|
const { response } = error;
|
|
const { data } = response;
|
|
const { message } = data;
|
|
|
|
toast(message, {
|
|
type: toast.TYPE.ERROR,
|
|
position: toast.POSITION.TOP_RIGHT,
|
|
});
|
|
}
|
|
|
|
return {
|
|
updateRestreamSettings,
|
|
};
|
|
} |