在node.js中编译代码时出现此错误,该如何解决?
RefernceError:提取未定义
这是我正在执行的功能,它负责从特定的电影数据库中恢复信息。
function getMovieTitles(substr){  
  pageNumber=1;
  let url = 'https://jsonmock.hackerrank.com/api/movies/search/?Title=' + substr + "&page=" + pageNumber;
  fetch(url).then((resp) => resp.json()).then(function(data) {
    let movies = data.data;
    let totPages = data.total_pages;
    let sortArray = [];
    for(let i=0; i<movies.length;i++){
        sortArray.push(data.data[i].Title);
     }
    for(let i=2; i<=totPages; i++){
           let newPage = i;
           let url1 = 'https://jsonmock.hackerrank.com/api/movies/search/?Title=' + substr + "&page=" + newPage;
          fetch(url1).then(function(response) {
              var contentType = response.headers.get("content-type");
              if(contentType && contentType.indexOf("application/json") !== -1) {
                return response.json().then(function(json) {
                  //console.log(json); //uncomment this console.log to see the JSON data.
                 for(let i=0; i<json.data.length;i++){
                    sortArray.push(json.data[i].Title);
                 }
                 if(i==totPages)console.log(sortArray.sort());
                });
              } else {
                console.log("Oops, we haven't got JSON!");
              }
            });
        }
  })
  .catch(function(error) {
    console.log(error);
  });   
}
          fetch不是标准的nodejs方法-您需要node-fetch
                fetch()是为浏览器设计的,然后在显然不见的第三方模块中反向移植到node.js。该request()或request-promise()库更多本地专为node.js的支持更广泛的使用Node.js语言,包括溪流,数不胜数的认证方法等选项...
                