Check of optionsResult.ok

d463677328f394199263bcac836735f0defd99f2

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +2 -0Showing whitespace changes
src/endpoints/stable-diffusion.js+2 -0
@@ -297,12 +297,14 @@ router.post('/generate', jsonParser, async (request, response) => {
297 try {297 try {
298 const optionsUrl = urlJoin(request.body.url, '/sdapi/v1/options');298 const optionsUrl = urlJoin(request.body.url, '/sdapi/v1/options');
299 const optionsResult = await fetch(optionsUrl, { headers: { 'Authorization': getBasicAuthHeader(request.body.auth) } });299 const optionsResult = await fetch(optionsUrl, { headers: { 'Authorization': getBasicAuthHeader(request.body.auth) } });
300 if (optionsResult.ok) {
300 const optionsData = /** @type {any} */ (await optionsResult.json());301 const optionsData = /** @type {any} */ (await optionsResult.json());
301 const isForge = 'forge_preset' in optionsData;302 const isForge = 'forge_preset' in optionsData;
302303
303 if (!isForge) {304 if (!isForge) {
304 _.unset(request.body, 'override_settings.forge_additional_modules');305 _.unset(request.body, 'override_settings.forge_additional_modules');
305 }306 }
307 }
306 } catch (error) {308 } catch (error) {
307 console.log('SD WebUI failed to get options:', error);309 console.log('SD WebUI failed to get options:', error);
308 }310 }