Issues (13)

app/webpage.js (3 issues)

1
const fs = require('fs')  
2
const request = require('request')
3
4
function saveWebpage (url, filePath) {  
5
  return getWebpage(url, filePath)
0 ignored issues
show
The call to getWebpage seems to have too many arguments starting with filePath.
Loading history...
6
    .then(writeFile)
7
}
8
9
function getWebpage (url) {  
10
  return new Promise (function (resolve, reject) {
11
    request.get(url, function (err, response, body) {
12
      if (err) {
13
        return reject(err)
14
      }
15
16
      resolve(body)
0 ignored issues
show
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
17
    })
18
  })
19
}
20
21
function writeFile (fileContent) {  
22
  let filePath = 'page'
23
  return new Promise (function (resolve, reject) {
24
    fs.writeFile(filePath, fileContent, function (err) {
25
      if (err) {
26
        return reject(err)
27
      }
28
29
      resolve(filePath)
0 ignored issues
show
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
30
    })
31
  })
32
}
33
34
module.exports = {  
35
  saveWebpage
36
}