この記事は 2023 年 05 月 01 日に投稿しました。

目次
リンク
1. はじめに
こんにちは、iOS のエディタアプリPWEditorの開発者の二俣です。
今回は業務で使用しているJavascriptのaxiosでHTTPステータスコードを使用する方法についてです。
2.JavascriptのaxiosでHTTPステータスコードを使用する
JavascriptのaxiosでHTTPステータスコードを使用するには、HttpStatusCode定数を使用します。
定数定義
| 定数名 | HTTPステータスコード |
|---|---|
| Continue | 100 |
| SwitchingProtocols | 101 |
| Processing | 102 |
| EarlyHints | 103 |
| Ok | 200 |
| Created | 201 |
| Accepted | 202 |
| NonAuthoritativeInformation | 203 |
| NoContent | 204 |
| ResetContent | 205 |
| PartialContent | 206 |
| MultiStatus | 207 |
| AlreadyReported | 208 |
| ImUsed | 226 |
| MultipleChoices | 300 |
| MovedPermanently | 301 |
| Found | 302 |
| SeeOther | 303 |
| NotModified | 304 |
| UseProxy | 305 |
| Unused | 306 |
| TemporaryRedirect | 307 |
| PermanentRedirect | 308 |
| BadRequest | 400 |
| Unauthorized | 401 |
| PaymentRequired | 402 |
| Forbidden | 403 |
| NotFound | 404 |
| MethodNotAllowed | 405 |
| NotAcceptable | 406 |
| ProxyAuthenticationRequired | 407 |
| RequestTimeout | 408 |
| Conflict | 409 |
| Gone | 410 |
| LengthRequired | 411 |
| PreconditionFailed | 412 |
| PayloadTooLarge | 413 |
| UriTooLong | 414 |
| UnsupportedMediaType | 415 |
| RangeNotSatisfiable | 416 |
| ExpectationFailed | 417 |
| ImATeapot | 418 |
| MisdirectedRequest | 421 |
| UnprocessableEntity | 422 |
| Locked | 423 |
| FailedDependency | 424 |
| TooEarly | 425 |
| UpgradeRequired | 426 |
| PreconditionRequired | 428 |
| TooManyRequests | 429 |
| RequestHeaderFieldsTooLarge | 431 |
| UnavailableForLegalReasons | 451 |
| InternalServerError | 500 |
| NotImplemented | 501 |
| BadGateway | 502 |
| ServiceUnavailable | 503 |
| GatewayTimeout | 504 |
| HttpVersionNotSupported | 505 |
| VariantAlsoNegotiates | 506 |
| InsufficientStorage | 507 |
| LoopDetected | 508 |
| NotExtended | 510 |
| NetworkAuthenticationRequired | 511 |
リファレンス
3. おわりに
HTTPステータスコードを自分で定義しようと思いましたが、すでにaxiosで定義されていました。
リンク
紹介している一部の記事のコードはGitlabで公開しています。
興味のある方は覗いてみてください。
私が勤務しているニューラルでは、主に組み込み系ソフトの開発を行っております。
弊社製品のハイブリッド OS Bi-OSは高い技術力を評価されており、特に制御系や通信系を得意としています。
私自身はiOS モバイルアプリやウィンドウズアプリを得意としております。
ソフトウェア開発に関して相談などございましたら、お気軽にご連絡ください。
また一緒に働きたい技術者の方も随時募集中です。
興味がありましたらご連絡ください。
EMAIL : info-nr@newral.co.jp / m-futamata@newral.co.jp
TEL : 042-523-3663
FAX : 042-540-1688

