Skip to content

Commit

Permalink
uploadData removed
Browse files Browse the repository at this point in the history
  • Loading branch information
EhsanParsania committed Jun 5, 2021
1 parent d4ddc7c commit 05cca6e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/DataGrid/DataGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Datagrid extends Component {
<td>{item['id']}</td>
{fields.map((field, fieldIndex) => {
return (
field === "avatar" ? <td key={fieldIndex}><Avatar src={item[field]}/></td> : <td key={fieldIndex}>{item[field]}</td>
field === "image" ? <td key={fieldIndex}><Avatar src={'http://localhost:3001'+item[field]}/></td> : <td key={fieldIndex}>{item[field]}</td>
)
})}
{/* <td>
Expand Down
12 changes: 10 additions & 2 deletions src/components/InputFile/InputFile.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@ class InputFile extends Component {
uploadFile() {
return new Promise(function (resolve, reject) {
const image = document.getElementById('input').files[0]
const name = document.getElementById('input-name').value
const age = document.getElementById('input-age').value
const gender = document.getElementById('input-gender').value

var data = new FormData();
data.append("image", image);
data.append("name",name)
data.append("age",age)
data.append("gender",gender)

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
Expand All @@ -30,7 +38,7 @@ class InputFile extends Component {
}
}
});
xhr.open("POST", "http://localhost:3001/upload");
xhr.open("POST", "http://localhost:3001/customers");
xhr.send(data);
})

Expand Down Expand Up @@ -83,7 +91,7 @@ class InputFile extends Component {
// console.log(isUpload,fileName)

//post input data to json-server
await this.uploadData()


// remove modal
this.props.closeModal(isUpload)
Expand Down

0 comments on commit 05cca6e

Please sign in to comment.