Skip to content

Commit d77e5ba

Browse files
committed
Fix put method
1 parent 8cdca12 commit d77e5ba

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

app/components/Client/Save/Client.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ class Client extends React.Component
6868
handleSubmit(event) {
6969

7070
let client = this.formatFormData();
71-
let method;
71+
let id;
7272
if (typeof client._id !== 'undefined') {
73-
method = 'put';
73+
id = client._id;
7474
}
7575

76-
ClientService.save(client, method).then((response) => {
76+
ClientService.save(client, id).then((response) => {
7777
this.context.router.push("/clients");
7878
}).catch((error) => {
7979

app/services/Client.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ const Client = {
2626
return axios.get(url.join('/'), this.getConfig());
2727
},
2828

29-
save(client, method = 'post') {
30-
if (method == 'put') {
31-
return axios.put(this.getEntryPoint().join('/'), client, this.getConfig());
29+
save(client, id = undefined) {
30+
if (id !== undefined) {
31+
let url = this.getEntryPoint();
32+
url.push(id);
33+
return axios.put(url.join('/'), client, this.getConfig());
3234
}
3335
return axios.post(this.getEntryPoint().join('/'), client, this.getConfig());
3436
}

0 commit comments

Comments
 (0)