Fix: issue where backend is being called twice
Build image / build (push) Successful in 2m14s
Details
Build image / build (push) Successful in 2m14s
Details
This commit is contained in:
parent
c48aad6cba
commit
6745abc9da
|
@ -1,4 +1,4 @@
|
||||||
FROM oven/bun:1 as install
|
FROM oven/bun:1 AS install
|
||||||
RUN mkdir -p /temp/prod
|
RUN mkdir -p /temp/prod
|
||||||
COPY package.json bun.lockb /temp/prod/
|
COPY package.json bun.lockb /temp/prod/
|
||||||
RUN cd /temp/prod && bun install --frozen-lockfile
|
RUN cd /temp/prod && bun install --frozen-lockfile
|
||||||
|
|
|
@ -52,26 +52,28 @@ export default function ImageModerator({
|
||||||
}
|
}
|
||||||
|
|
||||||
const getNewImage = () => {
|
const getNewImage = () => {
|
||||||
setImageData({ url: "", tags: [] });
|
if (isLoading) {
|
||||||
fetch(`${middlewareUrl}/image`, {
|
setImageData({ url: "", tags: [] });
|
||||||
method: "GET",
|
fetch(`${middlewareUrl}/image`, {
|
||||||
})
|
method: "GET",
|
||||||
.then((response) => {
|
|
||||||
if (!response.ok) throw new Error("Response was not ok");
|
|
||||||
return response.json();
|
|
||||||
})
|
})
|
||||||
.then((data) => {
|
.then((response) => {
|
||||||
const url = data.url;
|
if (!response.ok) throw new Error("Response was not ok");
|
||||||
const tags = data.tags;
|
return response.json();
|
||||||
setImageData({ url, tags });
|
})
|
||||||
})
|
.then((data) => {
|
||||||
.catch((error) => {
|
const url = data.url;
|
||||||
setImageAlt("Error");
|
const tags = data.tags;
|
||||||
console.error(error);
|
setImageData({ url, tags });
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.catch((error) => {
|
||||||
setIsLoading(false);
|
setImageAlt("Error");
|
||||||
});
|
console.error(error);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
setIsLoading(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(getNewImage, [isLoading]);
|
useEffect(getNewImage, [isLoading]);
|
||||||
|
|
Loading…
Reference in New Issue