File tree Expand file tree Collapse file tree 1 file changed +4
-12
lines changed Expand file tree Collapse file tree 1 file changed +4
-12
lines changed Original file line number Diff line number Diff line change 11const axios = require ( 'axios' ) ;
22const { Octokit } = require ( '@octokit/rest' ) ;
3- const fetch = require ( "node-fetch" ) ;
43
54const COMMIT_MESSAGE = 'Sync LeetCode submission' ;
65const LANG_TO_EXTENSION = {
@@ -64,7 +63,7 @@ async function commit(params) {
6463 {
6564 path,
6665 mode : '100644' ,
67- content : question_data + '\n' + '# Solution' + '\n' + '```' + submission . lang + ' \n' + submission . code + '\n' + '```' ,
66+ content : question_data + '\n \n ' + '# Solution' + '\n' + '```' + submission . lang + ' \n' + submission . code + '\n' + '```' ,
6867 }
6968 ] ;
7069
@@ -124,18 +123,11 @@ async function getQuestionData(titleSlug, leetcodeSession) {
124123 variables : { "titleSlug" : titleSlug } ,
125124 } )
126125
127- const requestOptions = {
128- method : 'POST' ,
129- headers,
130- body : graphql ,
131- redirect : 'follow'
132- } ;
133126
134127 try {
135- const response = await fetch ( "https://leetcode.com/graphql/" , requestOptions ) ;
136- const result = await response . text ( ) ;
137- const parsedResult = JSON . parse ( result ) ;
138- return parsedResult . data . question . content ;
128+ const response = await axios . post ( "https://leetcode.com/graphql/" , graphql , { headers} ) ;
129+ const result = await response . data ;
130+ return result . data . question . content ;
139131 } catch ( error ) {
140132 console . log ( 'error' , error ) ;
141133 }
You can’t perform that action at this time.
0 commit comments