{"id":29278140,"url":"https://github.com/sury4karmakar/nodejs-response","last_synced_at":"2025-10-04T04:57:30.565Z","repository":{"id":143241043,"uuid":"436317038","full_name":"sury4karmakar/NodeJS-Response","owner":"sury4karmakar","description":"⚡how to send a http response (html or json) to the frontend using vanilla node js","archived":false,"fork":false,"pushed_at":"2025-04-26T08:53:53.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-05T10:49:05.454Z","etag":null,"topics":["http-response","response","vanilla-nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sury4karmakar.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,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-12-08T16:31:14.000Z","updated_at":"2025-04-26T08:53:57.000Z","dependencies_parsed_at":"2025-06-17T02:05:50.862Z","dependency_job_id":"5418d47d-b489-402f-ad50-e12d91595854","html_url":"https://github.com/sury4karmakar/NodeJS-Response","commit_stats":null,"previous_names":["sury4karmakar/nodejs-response"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sury4karmakar/NodeJS-Response","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sury4karmakar%2FNodeJS-Response","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sury4karmakar%2FNodeJS-Response/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sury4karmakar%2FNodeJS-Response/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sury4karmakar%2FNodeJS-Response/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sury4karmakar","download_url":"https://codeload.github.com/sury4karmakar/NodeJS-Response/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sury4karmakar%2FNodeJS-Response/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278266895,"owners_count":25958733,"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","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["http-response","response","vanilla-nodejs"],"created_at":"2025-07-05T10:41:06.708Z","updated_at":"2025-10-04T04:57:30.547Z","avatar_url":"https://github.com/sury4karmakar.png","language":"JavaScript","readme":"# Sending Response To The Frontend\n\n- **res.writeHead** to set any response headers.\n\n```js\nres.writeHead(200, { \"Content-Type\": \"text/html\" });\n```\n\n- **res.write()** to send the actual content for the response. the content should be either raw html or json data.\n\n```js\nres.write(\"\u003ch1\u003eWelcome to vanilla node server\u003c/h1\u003e\");\n```\n\nor,\n\n```js\nres.write(JSON.stringify(data));\n```\n\n- **res.end()** to end the response.\n\n```js\nres.end();\n```\n\n## Send html response :\n\n```js\nres.writeHead(200, { \"Content-Type\": \"text/html\" });\nres.write(\"\u003ch1\u003eWelcome to vanilla node server\u003c/h1\u003e\");\nres.end();\n```\n\n## Send json response :\n\n```js\nres.writeHead(200, { \"Content-Type\": \"application/json\" });\nres.write(JSON.stringify(data));\nres.end();\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsury4karmakar%2Fnodejs-response","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsury4karmakar%2Fnodejs-response","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsury4karmakar%2Fnodejs-response/lists"}