image-20211103112513529
image-20211103151312058
上面的代码当第一个then里面中触发了error,那第二个then也会执行,并且会运行到response中,但获取到的response是undefined,所以error里面应该这样写:

202111081636362937117853-1653377088075

优化:

image-20211103152330366

再利用async与await进行优化:

202111081636362963203751