-
-
Save amandeepmittal/36f0e84cd89d534b3956fa1e35f51a4e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// api-user.js | |
export const registerUser = user => { | |
return fetch('/api/users/', { | |
method: 'POST', | |
headers: { | |
Accept: 'application/json', | |
'Content-Type': 'application/json' | |
}, | |
body: JSON.stringify(user) | |
}) | |
.then(response => { | |
return response.json(); | |
}) | |
.catch(err => console.log(err)); | |
}; | |
export const findUserProfile = (params, credentials) => { | |
return fetch('/api/users/' + params.userId, { | |
method: 'GET', | |
headers: { | |
Accept: 'application/json', | |
'Content-Type': 'application/json', | |
Authorization: 'Bearer ' + credentials.t | |
} | |
}) | |
.then(response => { | |
return response.json(); | |
}) | |
.catch(err => console.error(err)); | |
}; | |
export const deleteUser = (params, credentials) => { | |
return fetch('/api/users/' + params.userId, { | |
method: 'DELETE', | |
headers: { | |
Accept: 'application/json', | |
'Content-Type': 'application/json', | |
Authorization: 'Bearer ' + credentials.t | |
} | |
}) | |
.then(response => { | |
return response.json(); | |
}) | |
.catch(err => console.error(err)); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment