(projectId, chartId, drId, data)
| 74 | } |
| 75 | |
| 76 | export function updateDataRequest(projectId, chartId, drId, data) { |
| 77 | return (dispatch) => { |
| 78 | const token = cookie.load("brewToken"); |
| 79 | const url = `${API_HOST}/project/${projectId}/chart/${chartId}/dataRequest/${drId}`; |
| 80 | const method = "PUT"; |
| 81 | const body = JSON.stringify(data); |
| 82 | const headers = new Headers({ |
| 83 | "Accept": "application/json", |
| 84 | "Content-Type": "application/json", |
| 85 | "Authorization": `Bearer ${token}`, |
| 86 | }); |
| 87 | |
| 88 | dispatch({ type: FETCHING_DATA_REQUEST }); |
| 89 | return fetch(url, { method, body, headers }) |
| 90 | .then((response) => { |
| 91 | if (!response.ok) { |
| 92 | dispatch(addError(response.status, "Could not update the Data Request")); |
| 93 | throw new Error(response.status); |
| 94 | } |
| 95 | |
| 96 | return response.json(); |
| 97 | }) |
| 98 | .then((dataRequest) => { |
| 99 | dispatch({ type: FETCH_DATA_REQUEST_SUCCESS, dataRequest }); |
| 100 | return Promise.resolve(dataRequest); |
| 101 | }) |
| 102 | .catch((err) => { |
| 103 | dispatch({ type: FETCH_DATA_REQUEST_FAIL }); |
| 104 | return Promise.reject(err); |
| 105 | }); |
| 106 | }; |
| 107 | } |
| 108 | |
| 109 | export function deleteDataRequest(projectId, chartId, drId) { |
| 110 | return (dispatch) => { |
no test coverage detected