Spoonaulous Api 登录/注册页面无法正常工作

问题描述 投票:0回答:1

因此,对于一个测试项目,我尝试在 Spoonaulous Api 网站上创建一个帐户。现在,我已经在 Spoonaulous 的正常一侧创建了一个帐户,但是当我尝试登录或在 Spoonaulous 上创建帐户或任何其他内容时,它不起作用。我要么收到“请求失败,出现 404”,要么收到其他错误消息。

我在网上搜索过,没有找到任何结果。

javascript api spoonacular
1个回答
0
投票

对我来说工作得很好,我去 Spoonaulous 注册了一个帐户,从我的帐户的控制台窗口中获取了 api。我能够使用它。请参阅下面的片段。

    document.getElementById('fetchRecipes').addEventListener('click', function() {
            const apiKey = 'myapikey'; // Consider securing your API key
            const url = `https://api.spoonacular.com/recipes/findByIngredients?ingredients=apples,+flour,+sugar&number=2&apiKey=${apiKey}`;

            fetch(url)
                .then(response => response.json())
                .then(data => {
                    console.log(data); // Log the fetched recipes to the console
                })
                .catch(error => {
                    console.error('Error fetching data: ', error);
                });
        });
 <button id="fetchRecipes">Fetch Recipes</button>

© www.soinside.com 2019 - 2024. All rights reserved.