Как делать вызовы в Ускоренных мобильных страницах (AMP)? - PullRequest
0 голосов
/ 05 февраля 2020

Я пытаюсь выполнить вызов API GET и POST в ускоренных мобильных страницах (AMP). Я попытался javascript вызвать вызов, но он выдает ошибку с именем ". js был прерван из-за недопустимой мутации."

Я добавляю свой код, ниже которого я пытался

<!doctype html>
<html amp>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="amp-script-src" content="sha384-1-onAV4xFPXCNHk7IggErd7nDhuSLXcOG3Ef7uGtMyej-CZFiuvk16YcEWLb1Dmn">
    <title>Document</title>
    <link rel="canonical" href="/" />
    <script async src="https://cdn.ampproject.org/v0.js"></script>
    <script async custom-element="amp-script" src="https://cdn.ampproject.org/v0/amp-script-0.1.js"></script>
    <style amp-boilerplate>
        body {
            -webkit-animation: -amp-start 8s steps(1, end) 0s 1 normal both;
            -moz-animation: -amp-start 8s steps(1, end) 0s 1 normal both;
            -ms-animation: -amp-start 8s steps(1, end) 0s 1 normal both;
            animation: -amp-start 8s steps(1, end) 0s 1 normal both
        }

        @-webkit-keyframes -amp-start {
            from {
                visibility: hidden
            }

            to {
                visibility: visible
            }
        }

        @-moz-keyframes -amp-start {
            from {
                visibility: hidden
            }

            to {
                visibility: visible
            }
        }

        @-ms-keyframes -amp-start {
            from {
                visibility: hidden
            }

            to {
                visibility: visible
            }
        }

        @-o-keyframes -amp-start {
            from {
                visibility: hidden
            }

            to {
                visibility: visible
            }
        }

        @keyframes -amp-start {
            from {
                visibility: hidden
            }

            to {
                visibility: visible
            }
        }
    </style>
    <noscript>
        <style amp-boilerplate>
            body {
                -webkit-animation: none;
                -moz-animation: none;
                -ms-animation: none;
                animation: none
            }
        </style>
    </noscript>
</head>

<body>

    <amp-script  script="cookie-script">
        <div id="cookie-law">
        </div>
    </amp-script >
    <script target="amp-script" type="text/plain" id="cookie-script">
        fetch(myURl)
        .then(response => console.log(response))
    </script>
</body>

</html>

Я добавил фактический URL-адрес get вместо myUrl в коде, но консоль показывает вышеуказанную ошибку. Пожалуйста, помогите мне найти возможное решение. Спасибо.

...