title: How can axios get the status code in .catch()?
body: <p>In the <a href="https://github.com/axios/axios#handling-errors" rel="noreferrer">Axios</a> document:</p>
  
  <pre><code>axios.get('/user/12345')
    .catch(function (error) {
      if (error.response) {
        // The request was made and the server responded with a status code
        // that falls out of the range of 2xx
        console.log(error.response.data);
        console.log(error.response.status);
        console.log(error.response.headers);
      } else if (error.request) {
        // The request was made but no response was received
        // `error.request` is an instance of XMLHttpRequest in the browser and an instance of
        // http.ClientRequest in node.js
        console.log(error.request);
      } else {
        // Something happened in setting up the request that triggered an Error
        console.log('Error', error.message);
      }
      console.log(error.config);
    });
  </code></pre>
  
  <p>we know we can catch the <code>error</code> in the <code>.catch()</code> method.</p>
  
  <p>But when I use the Django-Rest-Framework as the backend API provider. it only provide the data, there is no status in it:</p>
  
  <p><kbd><a href="https://i.stack.imgur.com/Er197.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/Er197.jpg" alt="enter image description here"></a></kbd></p>
  
  <p>You see the <code>error</code>:</p>
  
  <pre><code>{username: ["A user with that username already exists."]}  
  </code></pre>
  
  <p>but in the browser, we can know the status code:</p>
  
  <p><kbd><a href="https://i.stack.imgur.com/pWlWy.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/pWlWy.jpg" alt="enter image description here"></a> </kbd></p>
  
  <hr>
  
  <p>Before asking this question, I have read <a href="https://stackoverflow.com/questions/39153080/how-can-i-get-the-status-code-from-an-http-error-in-axios">How can I get the status code from an http error in Axios?</a>
  this post.</p>
  
  <p>But the post seems different with mine.</p>
  
  <hr>
  
  <p><strong>EDIT-1</strong></p>
  
  <p>In my Django-Rest-Framework project:</p>
  
  <p>the view:</p>
  
  <pre><code>class UserCreateAPIView(CreateAPIView):
      serializer_class = UserCreateSerializer
      permission_classes = [AllowAny]
      queryset = User.objects.all()
  </code></pre>
  
  <p>the serializer:</p>
  
  <pre><code>class UserCreateSerializer(ModelSerializer):
      """
      user register
      """
      class Meta:
          model = User
          fields = [
              'username',
              'wechat_num',
              'password',
          ]
          extra_kwargs = {
              "password":{"write_only":True}
          }
  
      def create(self, validated_data):
          username=validated_data.pop('username')
          wechat_num = validated_data.pop('wechat_num')
          password=validated_data.pop('password')
  
          user_obj = User(
              username=username,
              wechat_num=wechat_num,
          )
          user_obj.set_password(password)
          user_obj.save()
          group=getOrCreateGroupByName(USER_GROUP_CHOICES.User)
          user_obj.groups.add(group)
  
          return validated_data
  </code></pre>