Writing my own synchronous function in Node

Open
#170 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
20/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
javascript, node.js
Domain
api, backend

Research direction

Start with the Node fs.js source linked in the issue and compare its synchronous routines with the desired HTTP call. The issue asks for basic-JavaScript pseudocode without promises or async/await; done would be a clear explanation of whether this synchronous behavior is possible. No repository file or test is identified.

Written by the indexing model from the issue text.

Description

TL;DR: If they can do it in the fs routines, it must be possible for me to do it in my own code, right??

In Frontier, you make a simple HTTP request this way:

htmltext = tcp.httpReadUrl ("http://scripting.com"/)

I want to do the same thing in Node.

No callback. Just return the contents of the page. If I want to catch the error I can put it inside try/catch.

I have tried reading the source for the fs sync routines. Eventually it will click and I'll see how to do this. If they can do it, presumably so can I. But I thought I'd ask if people can show me how to do this sooner.

The answer should be in pseudocode. No need to go into the details of making an actual HTTP request. And just use basic JavaScript, I don't want promises or async/await. I want it to be as simple as shown above. Thanks!

PS: The reason is I want to have Frontier-like scripting for Node-implemented websites. I want to use JavaScript syntax, not bash or Python. I like JS. ;-)

Dominant language
HTML
Stars
134
Forks
10
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from scripting/Scripting-News

All issues in scripting/Scripting-News

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.