Skip to content

Commit

Permalink
ADD :: search
Browse files Browse the repository at this point in the history
  • Loading branch information
anys34 committed Aug 27, 2023
1 parent 355278e commit 9334880
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions routes/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ const header = `headers: {
}`;

router.get("/:id", async (req, res) => {
const id = req.params.id;
const { id } = req.params;
const user_Info = [];
try {
const response = axios.get(`https://api.github.com/users/${id}`, {
const response = await axios.get(`https://api.github.com/users/${id}`, {
header,
});
const user = response.data;
Expand All @@ -32,7 +32,12 @@ router.get("/:id", async (req, res) => {
location: user.location,
commit: commit,
});
res.send(user_Info);
if (user_Info.length > 0) {
return res.send(user_Info);
}
if (!(user_Info.length > 0)) {
return res.send("not found");
}
} catch (error) {
console.log(error);
res.status(500).send(error);
Expand Down

0 comments on commit 9334880

Please sign in to comment.