mirror of
https://github.com/mue/mue.git
synced 2026-07-14 04:24:01 +02:00
webp support for api
This commit is contained in:
@@ -1,10 +1,15 @@
|
||||
//* Imports
|
||||
import React from 'react';
|
||||
import supportsWebP from 'supports-webp';
|
||||
|
||||
|
||||
export default class Background extends React.Component {
|
||||
async setBackground() {
|
||||
try { // First we try and get an image from the API...
|
||||
let data = await fetch('https://api.muetab.xyz/getImage?category=Outdoors');
|
||||
let requestURL;
|
||||
if (await supportsWebP) requestURL = 'https://api.muetab.xyz/getImage?webp=true';
|
||||
else requestURL = 'https://api.muetab.xyz/getImage?category=Outdoors';
|
||||
let data = await fetch(requestURL);
|
||||
data = await data.json();
|
||||
|
||||
document.getElementById('root').style.backgroundImage = `url(${data.file})`; // Set the background
|
||||
|
||||
Reference in New Issue
Block a user