現在、axios.postメソッドを用いてgraphqlのmutationをバックエンドで実行するスクリプトを作成しています。
認証のエラーが起きていたので、headerオブジェクトに「"Authorization: Basic ${token}
」と設定したのですが、
コンソール上に "TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["Authorization"]" と返ってきてしまいました。
こちらについて、解決方法をご存じでしょうか?
書いたコードです。
↓
axios({
url: endpoint,
method: "post",
headers: {
Authorization: Basic ${token}
,
},
data: {
query: mutation createCompany( $id: String! $isContractEvaluation: Boolean! $isContractReport: Boolean! $name: String! $shortName: String! $startMonth: Number! $url: String! ) { createCompany(id: $id, name: $name, startMonth: $startMonth) { id name startMonth } }
,
variables: {
input: {
id: process.argv[3],
name: process.argv[5],
startMonth: process.argv[9],
},
},
},
})
.then((res) => console.log(res))
.catch((err) => console.log("[失敗]", err));

あなたの回答
tips
プレビュー