0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【AxiosError:401】apiにアクセスできない

Posted at

参考記事

環境

Laravel9
Inertia
Vue3

エラー

以下のエラーが出てapiにアクセスできませんでした。

image.png

原因

パスの書き方を間違えていました。

修正前

index.vue
onMounted(() => {
    axios.get('/api/user')
    .then( res => {
        console.log(res)
    })
})

修正後

アドレス表記を修正したら、無事に操作できるようになりました。

index.vue
onMounted(() => {
    axios.get('http://127.0.0.1:8000/admin/purchases/create')
    .then( res => {
        console.log(res)
    })
})
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?