获取 Post 方法到达 API 时清空

Fetch Post Method Empty upon arrival at API

我正在尝试将网络推送订阅对象发送到我的 API,它由 'endpoint' 和 'keys'.

组成

我似乎遇到的问题是,当此对象到达我的 API 时,它具有 'Keys' 值,但 'endpoint' 值为空。然而,当我调试它时,我可以确认端点值已定义。

这是我使用的JS代码:

async function Subscribe() {
        let sw = await navigator.serviceWorker.ready;
        let push = await sw.pushManager.subscribe({
            userVisibleOnly: true,
            applicationServerKey:
                'ApplicationServerKeyHere'
        });
        console.log(JSON.stringify(push)); //Store this in DB

        fetch("https://localhost:44325/Subscribe", {
            method: "POST",
            //credentials: "same-origin", // include, *same-origin, omit
            headers: {
                "Content-Type": "application/json"
            },
            body: JSON.stringify(push)
        });
    }

在发送 Fetch POST 之前填充端点:

然后在到达API时为空:

传入的 JSON 具有 'endpoint' 作为字段,而您的 DOTNET 模型 class 作为 'enpoint' 作为字段(json-payload 中的字段名称不匹配和模型 class 将接受 json 有效载荷)