Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8e8fedf

Browse files
app crash solved
1 parent d56349f commit 8e8fedf

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

‎leetcode.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//graphql query
12
const query = `
23
query getUserProfile($username: String!) {
34
allQuestionsCount {
@@ -28,30 +29,36 @@ const query = `
2829
}
2930
}
3031
`;
31-
const variables = {
32-
username: "faisalshohagprog"
33-
};
34-
32+
//Test a menual user
3533
exports.leet = (req, res) => {
3634
fetch('https://leetcode.com/graphql', {
3735
method: 'POST',
3836
headers: {
3937
'Content-Type': 'application/json',
4038
'Referer': 'https://leetcode.com'
4139
},
42-
body: JSON.stringify({query: query, variables: variables}),
40+
body: JSON.stringify({query: query, variables: {username: "faisalshohagprog"}}),
4341

4442
})
4543
.then(result => result.json())
4644
.then(data => {
47-
res.send(formatData(data.data));
45+
if(data.errors){
46+
res.send(data);
47+
}else {
48+
if(data.errors){
49+
res.send(data);
50+
}else {
51+
res.send(formatData(data.data));
52+
}
53+
}
4854
})
4955
.catch(err=>{
5056
console.error('Error', err);
5157

5258
});
5359
}
5460

61+
// format data
5562
const formatData = (data) => {
5663
let sendData = {
5764
totalSolved: data.matchedUser.submitStats.acSubmissionNum[0].count,
@@ -71,6 +78,7 @@ const formatData = (data) => {
7178
return sendData;
7279
}
7380

81+
//fetching the data
7482
exports.leetcode = (req, res) => {
7583
let user = req.params.id;
7684
fetch('https://leetcode.com/graphql', {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /