Skip to content

Commit

Permalink
update the axios with vue3
Browse files Browse the repository at this point in the history
  • Loading branch information
joshua1988 committed Sep 17, 2023
1 parent 257ac03 commit 7b165d1
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/vue/axios.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ npm install axios
</div>
```

<code-group>
<code-block title="Vue 2">
```js
new Vue({
el: '#app',
Expand All @@ -48,6 +50,26 @@ new Vue({
}
})
```
</code-block>

<code-block title="Vue 3">
```js
Vue.createApp({
methods: {
fetchData: function() {
axios.get('https://jsonplaceholder.typicode.com/users/')
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log(error);
});
}
}
}).mount('#app')
```
</code-block>
</code-group>

위 코드는 get data 버튼을 클릭했을 때 사용자 정보를 받아오는 코드입니다. 실행하면 사용자 정보가 브라우저 개발자 도구의 콘솔에 출력됩니다.

Expand Down

0 comments on commit 7b165d1

Please sign in to comment.