Home>

Vue.js Using Vue.js, when posting on AXIOS, STATUS: 500 returns to CATCH.

AWAIT this.axios
    .post ('/User', Data)
    .Then (Response= >
 {
      Console.info (Response.Data)
      this.result= Response.Data
    })
    .catch (Error= >
 {
      Console.info (Error)
    })

Status: What is the way of error handling when 500 returns?
Thank you.

  • Answer # 1

    Self-solved.

    The log was displayed on the console in the following part, but
    This was misunderstood as a browser standard error log.

    .CATCH (Error= >
     {
      Console.info (Error)
    })
    
    

    CONSOLE.INFO (Error) result

    Error: Request Failed with Status Code 500
    AT CreateError (CreateError.js? 16D0: 16)
    AT SETTLE (SETTLE.JS? DB52: 18)
    AT XMLHTTPREQUEST.HANDLELOAD (XHR.JS? EC6C: 77)
    
    

    By CONST as follows, by determining STATUS,
    It seems that processing branches for every STATUS are possible.

    ASYNC GET404 () {
      const test= await this. $ AxIOS
        .get ('/404')
        .Then (Response= >
     {
          Console.info (Response.Data)
          this.result= Response.Data
        })
        .catch (Error= >
     {
          Console.info (Error)
          Return Error
        })
      IF (Test.Response.STATUS=== 404) {
        Console.info ('no page is found')
      }
    }