{"id":22912184,"url":"https://github.com/simplyyan/lymplerequest","last_synced_at":"2025-04-01T11:16:18.165Z","repository":{"id":231342861,"uuid":"781539608","full_name":"simplyYan/lympleRequest","owner":"simplyYan","description":"A small library for making easy requests in JS","archived":false,"fork":false,"pushed_at":"2024-04-03T15:52:57.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-07T06:22:46.266Z","etag":null,"topics":["backend","get","javascript","js","post","requests","server-side","vanilla-javascript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simplyYan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-04-03T15:17:22.000Z","updated_at":"2024-04-03T15:53:53.000Z","dependencies_parsed_at":"2024-04-03T16:49:01.120Z","dependency_job_id":null,"html_url":"https://github.com/simplyYan/lympleRequest","commit_stats":null,"previous_names":["simplyyan/lymplerequest"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplyYan%2FlympleRequest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplyYan%2FlympleRequest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplyYan%2FlympleRequest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplyYan%2FlympleRequest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simplyYan","download_url":"https://codeload.github.com/simplyYan/lympleRequest/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246628225,"owners_count":20808106,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backend","get","javascript","js","post","requests","server-side","vanilla-javascript"],"created_at":"2024-12-14T04:27:03.988Z","updated_at":"2025-04-01T11:16:18.147Z","avatar_url":"https://github.com/simplyYan.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"**Lymple**\n\nWelcome to the lympleRequest (lymple) - a lightweight JavaScript library for making GET and POST requests easily and efficiently. Communicate with your favorite back-end language, any language.\n\n### Introduction\n\nLymple is an easy-to-use tool for interacting with APIs and web servers directly from your browser. With it, you can asynchronously send and receive data, enabling the building of dynamic and interactive web applications.\n\n### Installation\n\nYou can use Lymple by either including the code directly in your JavaScript scripts or by saving it in a separate file and including it in your HTML.\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/gh/simplyYan/lympleRequest@main/lymple.js\"\u003e\u003c/script\u003e\n```\n\n### Basic Usage\n\n#### GET Requests\n\nTo make a GET request, you need to provide the URL of the resource you want to access and a callback function to handle the response.\n\n```javascript\nlymple.get('https://api.example.com/data', function(response) {\n    console.log(response); // Here you can process the response\n});\n```\n\n#### POST Requests\n\nTo make a POST request, in addition to the URL, you need to provide the data to be sent as a JavaScript object and a callback function to handle the response.\n\n```javascript\nvar data = { name: 'John', age: 25, city: 'New York' };\nlymple.post('https://api.example.com/submit', data, function(response) {\n    console.log(response); // Here you can process the response\n});\n```\n\n### More Details\n\n#### Error Handling\n\nLymple automatically handles network errors, such as connection failures or unexpected server responses. You can add error handlers to your callback function to deal with these situations.\n\n```javascript\nlymple.get('https://api.example.com/data', function(response) {\n    console.log(response);\n}, function(error) {\n    console.error('An error occurred:', error);\n});\n```\n\n#### Sending Custom Headers\n\nYou can send custom headers with your requests, such as authorization or content headers. Simply add an object containing the desired headers as the last parameter.\n\n```javascript\nvar headers = { 'Authorization': 'Bearer token123' };\nlymple.get('https://api.example.com/data', function(response) {\n    console.log(response);\n}, null, headers);\n```\n\n### Conclusion\n\nLymple is a powerful and versatile tool for handling HTTP communications in the browser. With its simple and easy-to-use design, you can easily integrate it into your projects to interact with APIs and web servers efficiently and reliably.\n\nIf you have any questions or suggestions, feel free to contact us!\n\n### Examples\n\n- **GET Request**: Fetching weather data from a weather API.\n\n```javascript\nlymple.get('https://api.weatherapi.com/forecast.json?key=YOUR_API_KEY\u0026q=London', function(response) {\n    console.log(response);\n});\n```\n\n- **POST Request**: Sending form data to the server.\n\n```javascript\nvar data = { name: 'Maria', age: 30, city: 'Rio de Janeiro' };\nlymple.post('https://api.example.com/submit', data, function(response) {\n    console.log(response);\n});\n```\n\n- **GENERAL EXAMPLE**:\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n    \u003cmeta charset=\"UTF-8\"\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"\u003e\n    \u003ctitle\u003eDocument\u003c/title\u003e\n    \u003cscript src=\"https://cdn.jsdelivr.net/gh/simplyYan/lympleRequest@main/lymple.js\"\u003e\u003c/script\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n    \u003cinput type=\"text\" name=\"nome\" id=\"nome\" placeholder=\"Type yout name\"\u003e\n    \u003cbutton onclick=\"send()\"\u003eSend\u003c/button\u003e\n    \u003cscript\u003e\n        function send() {\n            var nome = document.getElementById(\"nome\").value;\n            var data = { name: nome }\n\n            lymple.post('index.php', data, function(response) {\n                console.log(data)\n                console.log(response);\n            }, { 'Content-Type': 'application/json' });\n        }\n    \u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n```php\n\u003c?php\n\nif ($_SERVER[\"REQUEST_METHOD\"] == \"POST\") {\n\n    $data = json_decode(file_get_contents(\"php://input\"), true);\n\n    if (isset($data['name'])) {\n\n        $name = $data['name'];\n\n        echo \"The name sent is: \" . $name;\n    } else {\n\n        http_response_code(400);\n        echo \"The 'name' field was not found in the data.\";\n    }\n} else {\n\n    http_response_code(405);\n    echo \"Method not allowed. Only POST requests are accepted.\";\n}\n?\u003e\n```\n\nWith these examples, you can start using Lymple in your projects and leverage its features to enhance communication between your web application and servers.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplyyan%2Flymplerequest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimplyyan%2Flymplerequest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplyyan%2Flymplerequest/lists"}