FLUTTER_LEARN_IR Telegram 686
استاتوس کدها در Dio

▫️ بعضی از وب سرویس هایی که با اونها کار میکنیم در زمان رخ دادن خطا یا شرایط خاصی امکان داره که استاتوس کدهای مختلفی ارسال کنند.

برای مثال در یک وب سرویس احراز هویت در صورت رمز عبور اشتباه استفاده کردن از سمت سرور علاوه بر پیام استاتوس 410 یا هر مقدار دیگه ای دریافت بشه
در این حالت به صورت پیش فرض Dio به پیام دریافتی اعتنایی نمیکنه چون اعتبار سنجی اون براساس استاتوس کد 200 هست

▫️ برای رفع این مشکل از کلاس Options مقدار validateStatus را مقادیر مناسب میتونید شخصی سازی کنید.

 await Dio().post(url
options: Options(validateStatus: (status) => status! < 500));


در این مثال برنامه در صورت مواجه با استاتوس کدهای کمتر از 500 دچار Exception نمیشود.

⚜️اولین مرجع فارسی فلاتر @flutter_learn_ir



tgoop.com/flutter_learn_ir/686
Create:
Last Update:

استاتوس کدها در Dio

▫️ بعضی از وب سرویس هایی که با اونها کار میکنیم در زمان رخ دادن خطا یا شرایط خاصی امکان داره که استاتوس کدهای مختلفی ارسال کنند.

برای مثال در یک وب سرویس احراز هویت در صورت رمز عبور اشتباه استفاده کردن از سمت سرور علاوه بر پیام استاتوس 410 یا هر مقدار دیگه ای دریافت بشه
در این حالت به صورت پیش فرض Dio به پیام دریافتی اعتنایی نمیکنه چون اعتبار سنجی اون براساس استاتوس کد 200 هست

▫️ برای رفع این مشکل از کلاس Options مقدار validateStatus را مقادیر مناسب میتونید شخصی سازی کنید.

 await Dio().post(url
options: Options(validateStatus: (status) => status! < 500));


در این مثال برنامه در صورت مواجه با استاتوس کدهای کمتر از 500 دچار Exception نمیشود.

⚜️اولین مرجع فارسی فلاتر @flutter_learn_ir

BY آموزش برنامه نویسی فلاتر Flutter




Share with your friend now:
tgoop.com/flutter_learn_ir/686

View MORE
Open in Telegram


Telegram News

Date: |

It’s yet another bloodbath on Satoshi Street. As of press time, Bitcoin (BTC) and the broader cryptocurrency market have corrected another 10 percent amid a massive sell-off. Ethereum (EHT) is down a staggering 15 percent moving close to $1,000, down more than 42 percent on the weekly chart. During a meeting with the president of the Supreme Electoral Court (TSE) on June 6, Telegram's Vice President Ilya Perekopsky announced the initiatives. According to the executive, Brazil is the first country in the world where Telegram is introducing the features, which could be expanded to other countries facing threats to democracy through the dissemination of false content. While some crypto traders move toward screaming as a coping mechanism, many mental health experts have argued that “scream therapy” is pseudoscience. Scientific research or no, it obviously feels good. Polls Some Telegram Channels content management tips
from us


Telegram آموزش برنامه نویسی فلاتر Flutter
FROM American