Check of optionsResult.ok

d463677328f394199263bcac836735f0defd99f2

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

1 files changed, +6 -4Ignore whitespace
src/endpoints/stable-diffusion.js+6 -4
@@ -297,11 +297,13 @@ 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 const optionsData = /** @type {any} */ (await optionsResult.json());300 if (optionsResult.ok) {
301 const isForge = 'forge_preset' in optionsData;301 const optionsData = /** @type {any} */ (await optionsResult.json());
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');
306 }
305 }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);