'HttpError: invalid json response body at https://github.com/... Unexpected token o in JSON at position
Hello i'm fetching data from github api as follow from octokit
const octokit = new Octokit({
auth: "jhp_bOEN6EWOqtBcUBPIe0hlvEralCbNi0v2TE" //i've changed my github auth token)
});
and an onSubmit form as
const onSubmit = async (e) => {
e.preventDefault();
try {
const userData = await octokit.request(`GET /users/${inputValue}`, {
username: `${inputValue}`
});
console.log(userData, "userData came");
//setUser(userData);
} catch (err) {
console.log("error getting data", err);
setUser("Invalid user data");
}
};
but when user submit , I get this error all the time
HttpError: invalid json response body at https://api.github.com/users/something?username=something reason: Unexpected token o in JSON at position 1
at eval (https://wu68u9.csb.app/node_modules/@octokit/request/dist-web/index.js:99:11)
at async onSubmit (https://wu68u9.csb.app/src/Search.js:50:24)
Is there something wrong i'm doing here?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
