MCPcopy
hub / github.com/bradtraversy/devconnector_2.0 / createProfile

Function createProfile

client/src/actions/profile.js:93–118  ·  view source on GitHub ↗
(formData, edit = false)

Source from the content-addressed store, hash-verified

91// Create or update profile
92export const createProfile =
93 (formData, edit = false) =>
94 async (dispatch) => {
95 try {
96 const res = await api.post('/profile', formData);
97
98 dispatch({
99 type: GET_PROFILE,
100 payload: res.data
101 });
102
103 dispatch(
104 setAlert(edit ? 'Profile Updated' : 'Profile Created', 'success')
105 );
106 } catch (err) {
107 const errors = err.response.data.errors;
108
109 if (errors) {
110 errors.forEach((error) => dispatch(setAlert(error.msg, 'danger')));
111 }
112
113 dispatch({
114 type: PROFILE_ERROR,
115 payload: { msg: err.response.statusText, status: err.response.status }
116 });
117 }
118 };
119
120// Add Experience
121export const addExperience = (formData) => async (dispatch) => {

Callers 1

onSubmitFunction · 0.90

Calls 1

setAlertFunction · 0.90

Tested by

no test coverage detected