Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update spanish version #193

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
[Updated] post example page
  • Loading branch information
kevlg committed Jul 12, 2024
commit 4c31a031a96e8c7f91764d6f1a37a4bb6e963226
65 changes: 56 additions & 9 deletions posts/es/post_example.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
---
title: 'Peticion POST'
description: 'Como ejecutar una peticion POST con Axios'
title: 'Petición POST'
description: 'Como ejecutar una petición POST con Axios'
prev_title: 'Ejemplo Mínimo'
prev_link: '/es/docs/example'
prev_link: 'es/docs/example'
next_title: 'Axios API'
next_link: '/es/docs/api_intro'
next_link: 'es/docs/api_intro'
---

Ejecutando una peticion `POST`
## Ejecutando una petición `POST`

### JSON

```js
axios.post('/user', {
Expand All @@ -22,7 +24,7 @@ axios.post('/user', {
});
```

Ejecutando múltiples peticiones concurrentes
Ejecutando multiple peticiones concurrentes

```js
function getUserAccount() {
Expand All @@ -33,9 +35,54 @@ function getUserPermissions() {
return axios.get('/user/12345/permissions');
}

const [acct, perm] = await Promise.all([getUserAccount(), getUserPermissions()]);

// OR

Promise.all([getUserAccount(), getUserPermissions()])
.then(function (results) {
const acct = results[0];
const perm = results[1];
.then(function ([acct, perm]) {
// ...
});
```

Postear un Form HTML como JSON

```js
const {data} = await axios.post('/user', document.querySelector('#my-form'), {
headers: {
'Content-Type': 'application/json'
}
})
```

### Forms

- Multipart (`multipart/form-data`)

```js
const {data} = await axios.post('https://httpbin.org/post', {
firstName: 'Fred',
lastName: 'Flintstone',
orders: [1, 2, 3],
photo: document.querySelector('#fileInput').files
}, {
headers: {
'Content-Type': 'multipart/form-data'
}
}
)
```

- URL encoded form (`application/x-www-form-urlencoded`)

```js
const {data} = await axios.post('https://httpbin.org/post', {
firstName: 'Fred',
lastName: 'Flintstone',
orders: [1, 2, 3]
}, {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
})
```