node.js - Not Found Status :404
问题描述
This is my first question here, although I always come to this great community for guidelines. I am learning how to use GraphQL watched a few videos on how to set it up and work with it as a project. I am cloning my GitHub repositories with Node.js for server interactions. My query works perfectly in the GraphQL playground, so I moved on to get the same data in my local editor; using Axios, I set up my server like below.
const { default: Axios } = require("axios");
// const fetch = require("node-fetch");
const username = "myGithubUsername"
const token = "myGithubPersonalAccessToken"
const body = {
query:`
query {
user(login: ${username}){
name,
login,
bioHTML,
avatarUrl,
repositories(last: 10){
nodes{
name,
id,
forkCount
}
}
}
}`
}
const baseUrl = "https://api.github.com/graphql/";
const headers ={
"Content-Type": "application/json",
Authorization: `Bearer ${token}`
}
Axios.post(baseUrl,
{body: JSON.stringify(body)},
{headers: headers}).then((response) =>{
console.log('response', response.data)
}).catch((error) => {
console.log('error', error.response)})
Each time I serve it, I get Error: Status 404 Not Found.
I tried in PostMan using my Token, and it works perfectly too. Please let me know what I am doing wrong.
解决方案
推荐阅读
- c++ - 内存不足 C++
- c++ - 一维数组和三维数组使用一个模板
- angular - 尝试使用 webpack 构建 angular4 旧项目但失败
- c++ - 调整窗口大小时出现奇怪的伪影
- swift - 按顺序执行文本转语音
- javascript - 在javascript中将签名字段添加到pdf
- kotlin - org.springframework.data.mapping.MappingException 与 Kotlin 和密封类
- json - 尽管请求 JSON,Dynamic 365 API 仅返回 XML
- java - Windows 上的 Java 编译器不会创建可执行文件,只有 .class
- javascript - 如何在一定量的反应后使反应消失?