-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added sample user to database * fetching user information from database * fixed error messages * removed hardcoded user, tested it with requestly * added useParams hook * changed single quotation mark to support string interpolation * removed testing script
- Loading branch information
1 parent
52fe333
commit ce27e8e
Showing
3 changed files
with
16 additions
and
10 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,14 +4,18 @@ const User = db.User; | |
exports.get = async (req, res) => { | ||
//const users = await User.findAll(); | ||
|
||
const sampleUser = { | ||
username: 'Alexander Apostolu', | ||
preferredName: 'Alex', | ||
email: '[email protected]', | ||
score: 100 | ||
}; | ||
const { username: reqUsername } = req.params; | ||
|
||
res.status(200).json(sampleUser); | ||
if (!reqUsername) { | ||
return res.status(404).json({ message: "Requested username not found" }); | ||
} | ||
|
||
let user = await User.findOne({ where: { username: reqUsername } }); | ||
if (!user) { | ||
return res.status(500).json({ message: "User not found" }); | ||
} | ||
|
||
res.status(200).json(user); | ||
} | ||
|
||
exports.getSolutions = async (req, res) => { | ||
|
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