{"id":706,"date":"2024-11-04T11:13:32","date_gmt":"2024-11-04T11:13:32","guid":{"rendered":"http:\/\/localhost\/?p=706"},"modified":"2024-11-04T13:09:59","modified_gmt":"2024-11-04T13:09:59","slug":"test-api","status":"publish","type":"post","link":"https:\/\/studaca.online\/test-api\/","title":{"rendered":"test api"},"content":{"rendered":"\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <title>Text Analyzer<\/title>\n<\/head>\n<body>\n    <h1>Text Analysis Tool<\/h1>\n    <textarea id=\"inputText\" placeholder=\"Enter your text here...\" rows=\"5\" cols=\"50\"><\/textarea>\n    <br>\n    <button onclick=\"analyzeText()\">Analyze Text<\/button>\n\n    <h2>Results:<\/h2>\n    <div id=\"results\"><\/div>\n\n    <script>\n        \/\/ JavaScript function for analyzing text\n        async function analyzeText() {\n            const text = document.getElementById('inputText').value;\n\n            if (!text.trim()) {\n                alert('Please enter some text to analyze.');\n                return;\n            }\n\n            try {\n                const response = await fetch('http:\/\/localhost\/api\/v1\/analyze-text', {\n                    method: 'POST',\n                    headers: {\n                        'Content-Type': 'application\/json',\n                    },\n                    body: JSON.stringify({ text }),\n                });\n\n                if (!response.ok) {\n                    throw new Error('Text analysis failed');\n                }\n\n                const data = await response.json();\n                displayResults(data);\n            } catch (error) {\n                console.error('Text Analysis Error:', error);\n                document.getElementById('results').textContent = 'Error analyzing text.';\n            }\n        }\n\n        \/\/ Function to display the results\n        function displayResults(data) {\n            const resultsDiv = document.getElementById('results');\n            resultsDiv.innerHTML = `\n                <p>Total Errors: ${data.total_errors_count}<\/p>\n                <h3>Suggestions:<\/h3>\n                <ul>\n                    ${data.suggestions.map(suggestion => `\n                        <li>\n                            <strong>Message:<\/strong> ${suggestion.message}<br>\n                            <strong>Wrong Word:<\/strong> ${suggestion.wrongWord}<br>\n                            <strong>Replacements:<\/strong> ${suggestion.replacements.join(', ')}\n                        <\/li>\n                    `).join('')}\n                <\/ul>\n            `;\n        }\n    <\/script>\n<\/body>\n<\/html>\n\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Text Analyzer Text Analysis Tool Analyze Text Results:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-706","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/studaca.online\/api\/wp\/v2\/posts\/706","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/studaca.online\/api\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/studaca.online\/api\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/studaca.online\/api\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/studaca.online\/api\/wp\/v2\/comments?post=706"}],"version-history":[{"count":8,"href":"https:\/\/studaca.online\/api\/wp\/v2\/posts\/706\/revisions"}],"predecessor-version":[{"id":715,"href":"https:\/\/studaca.online\/api\/wp\/v2\/posts\/706\/revisions\/715"}],"wp:attachment":[{"href":"https:\/\/studaca.online\/api\/wp\/v2\/media?parent=706"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/studaca.online\/api\/wp\/v2\/categories?post=706"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/studaca.online\/api\/wp\/v2\/tags?post=706"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}