当我对一条消息执行socket.send()
时,我收到以下错误:Received message: {"type":"error","id":15,"payload":{"name":"TypeError","message":"iterator.next is not a function"}}
不确定显示此问题的原因以及如何修复它.此代码有错误:
socket.send(JSON.stringify(message))
以下是完整的代码:
export default function () {
const url =
"wss://test.com/graphql";
const query = `test ($scope: String = "DEFAULT", $test: Boolean = false) {
update(scope: $scope: $test) {
id
status
__typename
}
__typename
}
}
`;
const variables = {
scope: "DEFAULT",
topic: [
"football.*.6ec99981-9ffe-4722",
],
};
const params = {
headers: {
Authorization:
"testauth"
"Sec-WebSocket-Protocol": "graphql-ws",
Pragma: "no-cache",
},
};
const message = {
id: 15,
payload: { query, variables },
};
const response = ws.connect(url, params, function (socket) {
socket.on("open", function open() {
console.log("WebSocket connection established.");
// Send the GraphQL message
socket.send(JSON.stringify(message));
});