Здравствуйте!
Необходимо спарсить значение из JSON, однако выдается ошибка
Код:
const fetch = require("node-fetch");
var user = "NickProgramm";
let url = `https://api.github.com/user/${user}`;
let response = await fetch(url);
let commits = await response.json(); // читаем ответ в формате JSON
let result = JSON.parse(commits);
console.log(result);
Лог:
Лог(node:14639) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token o in JSON at position 1
at JSON.parse (<anonymous>)
at Object.module.exports.run (
:19)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:14639) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:14639) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.