Uncaught (in promise) Error: Request failed with status code 404 in Vuejs with axios get API

时间:2021-01-13 10:00:58

标签: javascript vue.js promise async-await axios

我在使用 axios 的 vuejs v2 中使用 API,在我尝试目录 1 工作之前,但我再次尝试目录不起作用。我不知道为什么 axios 配置是一样的

这是我的代码:

      try {
        const response = await this.axios.get("https://jsonplaceholder.typicode.com/users");
        this.users = response.data;
        console.log(response.data);
      } catch (error) {
        console.error("error diget, " + error);
      }
    }```

**im try to is code:**

``` this.axios.get("https://jsonplaceholder.typicode.com/users")
.then(Response => console.log(Response)))
.catch(Response => console.error(Response))```

but again and again its not working

error code :
``` Uncaught (in promise) Error: Request failed with status code 404
    at createAxiosError (utils.js?c786:148)
    at Object.settle (utils.js?c786:127)
    at handleRequest (handle_request.js?da0c:126)
    at eval (index.js?94db:26)
    at new Promise (<anonymous>)
    at MockAdapter.eval (index.js?94db:25)
    at dispatchRequest (dispatchRequest.js?5270:52) ```

0 个答案:

没有答案