MCPcopy Index your code
hub / github.com/chartbrew/chartbrew / createDataRequest

Function createDataRequest

client/src/actions/dataRequest.js:43–74  ·  view source on GitHub ↗
(projectId, chartId, data)

Source from the content-addressed store, hash-verified

41}
42
43export function createDataRequest(projectId, chartId, data) {
44 return (dispatch) => {
45 const token = cookie.load("brewToken");
46 const url = `${API_HOST}/project/${projectId}/chart/${chartId}/dataRequest`;
47 const method = "POST";
48 const body = JSON.stringify(data);
49 const headers = new Headers({
50 "Accept": "application/json",
51 "Content-Type": "application/json",
52 "Authorization": `Bearer ${token}`,
53 });
54
55 dispatch({ type: FETCHING_DATA_REQUEST });
56 return fetch(url, { method, body, headers })
57 .then((response) => {
58 if (!response.ok) {
59 dispatch(addError(response.status, "Could not create a data request"));
60 throw new Error(response.status);
61 }
62
63 return response.json();
64 })
65 .then((dataRequest) => {
66 dispatch({ type: FETCH_DATA_REQUEST_SUCCESS, dataRequest });
67 return Promise.resolve(dataRequest);
68 })
69 .catch((err) => {
70 dispatch({ type: FETCH_DATA_REQUEST_FAIL });
71 return Promise.reject(err);
72 });
73 };
74}
75
76export function updateDataRequest(projectId, chartId, drId, data) {
77 return (dispatch) => {

Callers 2

_onCreateNewRequestFunction · 0.90
_onCreateNewRequestFunction · 0.85

Calls 2

addErrorFunction · 0.90
dispatchFunction · 0.50

Tested by

no test coverage detected