Skip to content

关于SSE调用 #201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
BigworldNebula opened this issue Mar 7, 2025 · 0 comments
Open

关于SSE调用 #201

BigworldNebula opened this issue Mar 7, 2025 · 0 comments

Comments

@BigworldNebula
Copy link

感谢作者的贡献,我在使用此项目时,需要使用到SSE功能,同时需要鉴权,我在测试发现用service调用接口好像不能做SSE,我查阅到官方文档,使用的axios,但是是这样就没法鉴权了,以下是官方代码。
我的问题是如何保留鉴权功能情况下使用SSE功能,感谢你的解答。
https://node.cool-admin.com/src/guide/other/sse.html

const axios = require("axios");

const url = "http://127.0.0.1:8001/open/demo/sse/call";

const eventSource = axios.get(url, {
responseType: "stream",
});

eventSource.then((response) => {
// 收到消息
response.data.on("data", (event) => {
console.log("Message received:", event.toString());
});
// 发送结束
response.data.on("end", () => {
console.log("Connection closed");
});
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant