New Mars Forums

Official discussion forum of The Mars Society and MarsNews.com

You are not logged in.

Announcement

Announcement: As a reader of NewMars forum, we have opportunities for you to assist with technical discussions in several initiatives underway. NewMars needs volunteers with appropriate education, skills, talent, motivation and generosity of spirit as a highly valued member. Write to newmarsmember * gmail.com to tell us about your ability's to help contribute to NewMars and become a registered member.

#76 2022-10-18 08:07:23

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,182

Re: Java (r) or Javascript Computer Language

More for anyone studying the CORS vs JavaScript problem...

Per Google re Proxy Servers ...

why make a proxy server
Tom200
Get the Wallpaper App
ALLIMAGESVIDEOSMAPSNEWSSHOPPINGMORE
2,890,000,000 ResultsAny time

A proxy server helps the clients to protect their important information from getting hacked by hackers.
A proxy server is also used in bypassing blocked websites. ...
The proxy server is also used to enhance the security and privacy level of the client’s device while doing surfing using different proxies. ...
More items
The Advantages and Disadvantages of Proxy Server - RS Web Sol…
www.rswebsols.com/tutorials/technology/proxy-server-advantages-disadvantages
www.rswebsols.com/tutorials/technology/proxy-server-advantages-disadvantages
Was this helpful?
People also ask
What is a proxy server and why do you need it?
What are the risks of using proxy servers?
What is the main purpose of a proxy server?
Is it legal to use proxy servers?
Feedback
11 Reasons Why You Should Start Using the Proxy Server

https://www.temok.com/blog/using-proxy-server
8/6/2019 · In the companies, the proxy servers are used to prevent the employees to access the websites that are not secured. By using them, the internet usage …

Reviews: 3
Estimated Reading Time: 11 mins
EXPLORE FURTHER
Global web icon
What is a proxy server and why might I want to use one?
answers.microsoft.com
Global web icon
5 Reasons Your Company Should Use Proxy Servers - CMSWi…
cmswire.com
Global web icon
When and why should you use a proxy server? | Top Ten Revi…
toptenreviews.com
Global web icon
The Advantages and Disadvantages of Proxy Server - RS We…
rswebsols.com
Global web icon
What Are the Benefits of Using a Proxy Server? - CactusVPN
cactusvpn.com
Recommended to you based on what's popular • Feedback
What Are Proxy Servers and Why Do We Use Them? - new …
https://www.newtarget.com/web-insights-blog/what...
8/27/2021 · WHY WE USE PROXY SERVERS. 1. To Safeguard Corporate and Institutional Security. Hackers are everywhere these days, and every organization is vulnerable to security breaches to ... 2. You Can Share Internet Connections. Most small businesses have multiple …

Videos of Why Make a Proxy Server
bing.com/videos
How To Make Your Own Proxy Server For Free
6:44
How To Make Your Own Proxy Server For Free
247K viewsDec 1, 2018
YouTubeTricknology
What is a Proxy Server & How Does it work?
9:46
What is a Proxy Server & How Does it work?
3.2K views5 months ago
YouTubeThe TechCave
What is a Proxy Server?
4:43
What is a Proxy Server?
1.2M viewsAug 8, 2019
YouTubePowerCert Animated Videos
Proxy In 5 Minutes | What Is A Proxy? | What Is A Proxy Server? | Proxy Explained | Simplilearn
5:27
Proxy In 5 Minutes | What Is A Proxy? | What Is A Proxy Serve…
15K views9 months ago
YouTubeSimplilearn
Episode #341: Introduction to Using Squid Web Proxy Server
35:21
Episode #341: Introduction to Using Squid Web Proxy Server
250K viewsDec 4, 2012
YouTubeEli the Computer Guy
See more videos of Why Make a Proxy Server
Why should we use a proxy server? | Briskinfosec
https://www.briskinfosec.com/blogs/blogsdetail/Why...
Proxy servers add another layer of security between your servers and traffic from outside your network. You may also want to keep an eye on what your employees do online, such as the emails they send, the websites they visit, and the chat logs they send.

Phone: (860) 863-4123
Why Would You Need a Proxy Server? - TechStory
https://techstory.in/why-would-you-need-a-proxy-server
12/1/2021 · network server room with computers for digital tv ip communications and internet. When it comes to protecting your data online, there’s often no better choice than a proxy. These services can be an excellent way to enhance your security when browsing the web, as well as …

What is a Proxy Server? How It Works & How to Use It
https://www.fortinet.com/resources/cybe … oxy-server
A proxy server is a system or router that provides a gateway between users and the internet. Therefore, it helps prevent cyber attackers from entering a private network. It is a server, referred to as an “intermediary” because it goes between end-users and the web pages they visit online.

What is a proxy server?
A proxy server is a system or router that provides a gateway between users and the internet. Therefore, it helps prevent cyber attackers from enter...
How does a proxy server work?
Because a proxy server has its own IP address, it acts as a go-between for a computer and the internet. Your computer knows this address, and when...
Proxy server vs. VPN?
On the surface, proxy servers and virtual private networks (VPNs) may seem interchangeable because they both route requests and responses through a...
What are benefits of a proxy server?
The benefits of a proxy server include enhanced security, private browsing, watching, and listening, access to location-specific content, and preve...
Why you should use a proxy server with Create React App
https://blog.logrocket.com/why-you-shou … -react-app
3/22/2022 · Proxy servers add an extra degree of protection by allowing server responses to be validated before being delivered to the client. They can be used as web filters and firewalls. To avoid crashes, bandwidth must be conserved and server traffic must be regulated.

What is a Proxy Server and How Does it Work? - Varonis
https://www.varonis.com/blog/what-is-a-proxy-server
5/21/2018 · Proxy servers act as a firewall and web filter, provide shared network connections, and cache data to speed up common requests. A good proxy server keeps users and the internal network protected from the bad stuff that lives out in the wild internet. Lastly, proxy servers can …

5 Reasons Why Your Company Needs A Proxy Server
https://goandgrowonline.com/5-reasons-why-your...
7/9/2021 · A proxy server can store a temporary copy of a web page that it stores locally so that when your colleague visits the same site later, the proxy server can serve that copy instead of retrieving the original from the Internet. This is most useful for frequently visited websites, for …

What Are Proxy Servers & Why Do I Need One?
https://wanderingoffice.com/proxy-server
Now, proxy servers act as a firewall and web filter, provide secure shared network connections, and cache data to speed up common requests. That way, you’ll be getting security, which would pass a value for your time spent, and your information in record time.

The Advantages and Disadvantages of Proxy Server - RS …
https://www.rswebsols.com/tutorials/technology/...
5/18/2020 · A proxy server helps the clients to protect their important information from getting hacked by hackers. A proxy server is also used in bypassing blocked websites. It happens many a time that in some offices or schools or in... The proxy server is also used to enhance the …

Proxy Server | Best Proxy ip 2022 | Never get blocked
https://www.lunaproxy.com
AdPremium IP Proxy. 99.9% Uptime. Exclusive IP Proxy. Now Only $1.2/GB. 90M+ Residential IPs in 190+ Locations Worldwide. High Anonymity. Sign Up For Free Trial

Purchase Proxies · Static Residential IPs · Sign up for Get Free Test · luna proxy Now Only $2/GB

Service catalog: Best Proxy ip 2022, luna proxy Now Only $2/GB, Purchase Proxies
How To Be A Proxy Server - Learn More Today
https://study.com/academy/proxy
AdOver 27,000 video lessons and other resources, you're guaranteed to find what you need. Learn faster. Stay motivated. Study smarter.

study.com has been visited by 100K+ users in the past month

Courses: English language arts, Algebra I, Geometry, Algebra II, Global history
Best Proxies for IPv4 to IPv6 | Private Proxies and VPN
https://www.bestproxyandvpn.com/clean/socks-5-proxy
2K+ Facebook followers
AdPremium Private Proxy and VPN Provider. Try Our Free Package Selector Today! Exclusive Static Dedicated IPS. Https or Socks Proxies. Refund in 72 Hours. Order Now!

Related searches for why make a proxy server

Good Grief!

(th)

Offline

#77 2022-10-18 08:37:42

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,182

Re: Java (r) or Javascript Computer Language

More for anyone studying the CORS vs JavaScript issue ...

https://www.thisdot.co/blog/how-to-solv … er-and-koa

The article at the link above appears to be offering a way to make a local proxy server.

(th)

Offline

#78 2022-10-18 12:24:19

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,182

Re: Java (r) or Javascript Computer Language

Following up from Post #77

Linux (in various flavors) and Windows (in various flavors) are running at this location.

Google suggested a Linux package called Squid, so i installed it on a work station.

Apparently this is a proxy server that can run on a work station and does not need a fully configured server.

squid.service - Squid Web Proxy Server
     Loaded: loaded (/lib/systemd/system/squid.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2022-10-18 14:19:12 EDT; 45s ago
       Docs: man:squid(8)
    Process: 48673 ExecStartPre=/usr/sbin/squid --foreground -z (code=exited, status=0/SUCCESS)
   Main PID: 48676 (squid)
      Tasks: 4 (limit: 8771)
     Memory: 15.8M
        CPU: 216ms
     CGroup: /system.slice/squid.service
             ├─48676 /usr/sbin/squid --foreground -sYC
             ├─48678 "(squid-1)" --kid squid-1 --foreground -sYC
             ├─48682 "(logfile-daemon)" /var/log/squid/access.log
             └─48683 "(pinger)"

Oct 18 14:19:12 tahanson-GA-78LMT-S2P squid[48678]: Max Swap size: 0 KB
Oct 18 14:19:12 tahanson-GA-78LMT-S2P squid[48678]: Using Least Load store dir selection
Oct 18 14:19:12 tahanson-GA-78LMT-S2P squid[48678]: Set Current Directory to /var/spool/squid
Oct 18 14:19:12 tahanson-GA-78LMT-S2P squid[48678]: Finished loading MIME types and icons.
Oct 18 14:19:12 tahanson-GA-78LMT-S2P squid[48678]: HTCP Disabled.
Oct 18 14:19:12 tahanson-GA-78LMT-S2P squid[48678]: Pinger socket opened on FD 14
Oct 18 14:19:12 tahanson-GA-78LMT-S2P squid[48678]: Squid plugin modules loaded: 0
Oct 18 14:19:12 tahanson-GA-78LMT-S2P squid[48678]: Adaptation support is off.
Oct 18 14:19:12 tahanson-GA-78LMT-S2P squid[48678]: Accepting HTTP Socket connections at conn3 local=[::]:3128 remote=[::] FD 12 flags=9
Oct 18 14:19:13 tahanson-GA-78LMT-S2P squid[48678]: storeLateRelease: released 0 objects
~

(th)

Offline

#79 2022-10-18 18:56:05

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,182

Re: Java (r) or Javascript Computer Language

For SpaceNut (primarily) ... all others welcome ...

The local Linux SIG meeting just wound down.... the members have a generous amount of time to the JavaScript CORS problem.

We spend most of that time watching the developer features of the Safari Web Browser step through the operation of the script from one of the Dropbox saves.   We did not come up with a firm direction for resolution of the problem, but I learned a LOT about how to use the developer tools of the browser.  We shifted to my computer, so the group could watch the behavior of the system while I was logged in as a user on the NewMars system.

I had hoped we might have had time to look at the Squid proxy server, but that did not happen.

One member took a copy of the link to the Dropbox file, so there is a chance he might work with it over the next month.

(th)

Offline

#80 2022-10-19 10:17:25

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,182

Re: Java (r) or Javascript Computer Language

For SpaceNut (primarily) ... all others welcome...

This topic records (or attempts to record) progress in building a small application in JavaScript.

While the application itself would only be useful to SpaceNut, JavaScript is capable of serving practically anyone on Earth, and if they are users of the internet, JavaScript is probably involved at some point in their activity.

The present initiative has encountered a roadblock, called CORS.

This roadblock is designed to prevent, or at least slow down hacker attacks.

If the NewMars server were configured with a special access feature, then a qualifying web browser could run JavaScript to access resources.

However, such a special access feature is Not in place, and there is no prospect there will be one.

In the absence of the server granting access to a specific request, it appears that use of a proxy server may provide the security that is needed ** and ** deliver of information from NewMars.

https://brianschiller.com/blog/2021/10/ … th-a-proxy

The article at the link above appears to offer guidance on how to set up a proxy server to assist with the current project.

(th)

Offline

#81 2022-10-19 20:13:40

SpaceNut
Administrator
From: New Hampshire
Registered: 2004-07-22
Posts: 28,884

Re: Java (r) or Javascript Computer Language

I know that if I had the old internet explorer one could do a target capture of the total links code to see what was required but it seems that we no longer have that built in unless it's hidden in the development tools.

Our machines at work have had googles chrome removed and I would be that it's only a matter of time before Firefox as well will be removed.

Will look for small server code while you continue your learning.

https://www.digitalcitizen.life/how-set … indows-10/

https://support.microsoft.com/en-us/win … 1deee8dae1

https://learn.microsoft.com/en-us/previ … 2(v=ws.11)

https://beebom.com/how-to-set-up-a-prox … ve-method/

Study time tomorrow as headache is setting in....good night, all

Offline

#82 2022-10-19 20:49:24

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,182

Re: Java (r) or Javascript Computer Language

For SpaceNut re #81

Thanks for your thoughts on IE and other browsers, and news of software policy in a large organization with security concerns.

While you're looking, see if Squid is available for Windows.  It may be.  I understand it has been around for a number of years.

last night's Linux meeting was deep into bits and bytes for a solid hour.  The small group that attends these Zoom sessions are (almost) all experienced programmers with (in some cases) decades of experience.  The little problem i offered them is/was an opportunity to catch up on developments in JavaScript since 2015.

As I reported last night, the ** real ** eye opener for me was to see Apple Safari able to perform step operation of the script, which I have here-to-fore only seen in an IDE like Visual Studio or Eclipse.

(th)

Offline

#83 2022-10-27 08:01:42

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,182

Re: Java (r) or Javascript Computer Language

It's been a few days since I had a chance to work on the JavaScript for TestID updates ... today, I started over after following some unproductive branches.

It appears that the output I requested actually showed up!

<td class="tcl"><a href="profile.php?id=422387">TestID12345</a></td>
                    <td class="tc2">Member</td>
                    <td class="tc3">0</td>
                    <td class="tcr">2017-06-14</td>

The total amount of data returned from NewMars by the Fetch using a demo Proxy server was substantial.

Now that the demo proxy server is delivering results, I'll focus on how to set up a local proxy server to do the same thing.

Here is a link to the version that works:
https://www.dropbox.com/s/9hepwrae4k7ae … 4.htm?dl=0

If you (or anyone) decide(s) to run this in a browser, please note that the first time will generate a message from the demo proxy server. Just follow the link they provide, and click on the "one time test" button. Then the script will run.
Also please note that output is presently going to console.log, so you need to activate that in Tools >> Developer Tools

Update at 19:37 local time ...

I downloaded the file at the link above and ran it on a Windows 7 system using Edge.
To my surprise, the NewMars page arrived intact

<tr>
                    <td class="tcl"><a href="profile.php?id=422387">TestID12345</a></td>
                    <td class="tc2">Member</td>
                    <td class="tc3">0</td>
                    <td class="tcr">2017-06-14</td>
                </tr>

The demo Proxy site has a time limit, but apparently it extends this far into the day after permission to use the site was granted.

Update at 21:16 local time....

The file at the link above was downloaded an run on Ubuntu 22.04 using Chomium. Operation was flawless once again.

The permission at the demo Proxy site is still holding.

<tr>
                    <td class="tcl"><a href="profile.php?id=422387">TestID12345</a></td>
                    <td class="tc2">Member</td>
                    <td class="tc3">0</td>
                    <td class="tcr">2017-06-14</td>
                </tr>

Tomorrow, if time permits, I'll attempt to configure a local proxy server to perform the security service needed to satisfy CORS.

(th)

Offline

#84 2022-10-29 09:26:11

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,182

Re: Java (r) or Javascript Computer Language

For SpaceNut (primarily - all others welcome)

Today I began investigation of how to locate strings within the text returned from NewMars.... In JavaScript, the string type has multiple properties and multiple methods.  The details are shown at www.w3school.com

I read the instructions at the demo proxy site, and learned that a permission to use the site for development lasts for a day, and there is a limit of (I think) 50 requests per day.  We can use the demo site while trying to figure out how to use Squid on our own systems.

Here is another view of the table returned by FluxBB when we ask for information about TestID12345

<tbody>
                <tr>
                    <td class="tcl"><a href="profile.php?id=422387">TestID12345</a></td>
                    <td class="tc2">Member</td>
                    <td class="tc3">0</td>
                    <td class="tcr">2017-06-14</td>
                </tr>
            </tbody>

There is probably a way to read that html directly, but for now I am just working with text.

The information that is of interest in a fetch, is the confirmation the username exists, that it has a profile, and that the status is either member or banned.

After the username has been removed from the bans table, the status should be member.

I'm thinking of using the string method "includes" but am hesitating because TestID12345 shows up twice in the data returned by FluxBB.  The method 'includes" returns only true or false.  The result would always be true if the search value in the username window is TestID12345, as I expect it would be even if the name does not exist in the database.

TestID1234 shows up in the username request window, and it shows up in the table display from the query.

The "match" method returns an array, but I haven't tried it yet.

A reasonable study approach might be to try some of the methods that make sense, and go with the one(s) that make the most sense.

(th)

Offline

#85 2022-10-29 11:26:31

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,182

Re: Java (r) or Javascript Computer Language

For SpaceNut ....

This opportunity is open to all.

Would you be willing to undertake a parallel investigation of Squid on Windows 10?

I'm planning to attempt to learn how to use Squid on Ubuntu to forward URL requests from JavaScript running in a browser.

However, my first priority is to try to learn how to produce useful output to the operator from the text delivered by FluxBB in response to a request for Username TestID12345.  If you were able to find some time, I'd appreciate your attempting to feed the URL generated by JavaScript to the local Squid.

The format might be something like: http://123.456.789.111:3128/the url to NewMars

So far, I have not achieved success.  There could be a problem with the format of the URL, or there could be something lacking in configuration of the Squid service.

(th)

Offline

#86 2022-10-29 11:46:34

SpaceNut
Administrator
From: New Hampshire
Registered: 2004-07-22
Posts: 28,884

Re: Java (r) or Javascript Computer Language

The issue is the web view of the page is just only the display of information and not the total code which happens when you click on a link.
To display the source code for a page is possible from the web browser.
For edge you can open it in the developer tools. The older browsers have a view source function. These are all in a text format for the html that is how the display is happening.

Offline

#87 2022-10-29 14:00:40

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,182

Re: Java (r) or Javascript Computer Language

For SpaceNut re #86

Thank you for your continued support of and engagement with this initiative!

If you can figure out how to deliver the JavaScript Fetch request to Squid running on your Windows 10, it might be enough to put this mini-project over the goal line.  I am fresh from watching a college football team pull a win out of imminent defeat, so the metaphor of your providing an assist for the ball carrier is in mind.

As things stand, the version of the test JavaScript that was last posted is able to pull the Userlist web page from NewMars.

The information for TestID12345 is buried inside the text that is returned by Fetch.

I took a look at the search methods today, and discovered/learned that there are about 20 different commands available.

The "include" command provides a simple True/False response if a string is inside a response.

That might be the right command to use to determine if the response is worth pursuing.

If the response is "True" then there are commands to determine how many instances of the desired string may be present.

In the case of a simple lookup for TestID12345 in the Users table, there are two instances.  The first is a display of the name in the search window, and the second is the display in the query return table.

I'll attempt to work through some of the options tomorrow.

If you can get the sample program running on your Windows 10 machine, using your local Squid, that would help a ** lot **.

At this point, I do not know:

1) how to configure the URL inside JavaScript to direct the Fetch to the local proxy and ...
2) how to set up Squid to perform the forwarding service that is needed.

(th)

Offline

#88 2022-10-30 06:59:47

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,182

Re: Java (r) or Javascript Computer Language

For SpaceNut re Proxy Server challenge ...

Here is a web resource that Google found when I asked for help with setting up a URL in JavaScript to write to a local Squid proxy.

https://wiki.squid-cache.org/SquidFaq/CompleteFaq

Someone(s) went to a lot of effort to create that web site!

We have two parallel tracks in progress to achieve a working JavaScript TestID update utility.

I'm offering you (SpaceNut) the opportunity to solve the proxy problem.

I'm planning to work on the JavaScript today, by learning more about the String Methods.

My immediate goal is to pull tiny bits of information from the flood of text that arrives with a successful Fetch from the NewMars Users table for TestID12345.

You can see that flood for yourself, by running the most recent test file from Dropbox.

As a reminder: you'll need to request permission to use the demo proxy server.

And! You'll need to set up Developer tools>> console.log in your browser.

(th)

Offline

#89 2022-10-30 10:38:15

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,182

Re: Java (r) or Javascript Computer Language

FYI SpaceNut ....

As you proceed with the local proxy challenge, here is a snippet from Wikipedia about the 112 status code:

This status code is showing up in the output from the Proxy Demo while testing Fetch from the NewMars server:

https://en.wikipedia.org/wiki/List_of_HTTP_status_codes

Caching warning codes
The following caching related warning codes are specified under RFC 7234. Unlike the other status codes above, these are not sent as the response status in the HTTP protocol, but as part of the "Warning" HTTP header.[94][95] Since this header is often neither sent by servers nor acknowledged by clients, it was obsoleted by the HTTP Working Group with RFC 9111.

110 Response is Stale
The response provided by a cache is stale (the content's age exceeds a maximum age set by a Cache-Control header or heuristically chosen lifetime).
111 Revalidation Failed
The cache was unable to validate the response, due to an inability to reach the origin server.

112 Disconnected Operation
The cache is intentionally disconnected from the rest of the network.

(th)

Offline

#90 2022-10-30 11:15:00

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,182

Re: Java (r) or Javascript Computer Language

For SpaceNut .... Here is a preliminary (incorrect) result of my attempt to pull data from the "result" variable after a Fetch of "TestID12345" using JavaScript...

Run Status

Progress detail is to be reported here
Current ID is: 12345 After Fetch - should NOT appear
This version ran on Edge on Windows 10

The program is no longer generating compile time errors, but it is not delivering requested data either.  I have to break off here to attend to some chores.

My guess is that the flow of data via "return" is not doing what I was expecting.
***
The TestID update script is running and it has processed 278 ID's so far.

Based on past runs, it will fail before it reaches the goal of 18375.

(th)

Offline

#91 2022-10-30 18:13:42

SpaceNut
Administrator
From: New Hampshire
Registered: 2004-07-22
Posts: 28,884

Re: Java (r) or Javascript Computer Language

I have not looked through this, but it seems to be what we are attempting to do.
https://stackoverflow.com/questions/298 … ng-php-pdo

This one has other such builds
https://www.codegrepper.com/code-exampl … +login+php

Offline

#92 2022-10-30 20:15:24

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,182

Re: Java (r) or Javascript Computer Language

For SpaceNut re Proxy challenge.... thanks for thinking further about this part of the problem.  I am going to have my hands full trying to ferret out how to pull data from the Fetch that is now working.  I am contending with scope of variables right now.  The data from NewMars is in a variable called result (because we can see it in the console.log), but I have not yet figured out how to capture that data so I can work with it after result goes away.

I've spent a couple of hours learning things that don't work.

I am trying to make a version of the sample program that does NOT require console.log to see output, but I'm not "there yet".

(th)

Offline

#93 2022-10-30 20:46:27

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,182

Re: Java (r) or Javascript Computer Language

For SpaceNut re JavaScript Fetch mysteries ....

The code snippet below, from StackOverflow, may hold a clue to the solution:

var obj;

fetch('https://jsonplaceholder.typicode.com/posts/1')
  .then(res => res.json())
  .then(data => {
    obj = data;
   })
  .then(() => {
    console.log(obj);
   });

I've been able to work with the data inside the Fetch procedure, but not outside it.  The code snippet ** appears ** to offer a clue about how to copy the data from the "result" variable to another variable that survives exit from the Fetch.

(th)

Offline

#94 2022-10-31 12:00:58

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,182

Re: Java (r) or Javascript Computer Language

For SpaceNut ... The difficulty I've been reporting recently is (apparently) a consequence of the asynchronous environment inside a Fetch block.  The console.log reporting mechanism is misleading. It ** seems ** to report data but in fact (I'm now pretty sure) it is NOT reporting until data is available.

The "secret" appears to have something to do with "promises".  The Fetch command receives a "promise" almost immediately, and it receives data some time later (or not at all).

I've been trying to capture data inside the Fetch block, and there is never anything there.  I suspect (subject to correction) that I am pulling data upon receipt of the "promise".

Apparently, the solution is to introduce another asynchronous "await" into the mix, so that the variable to which I am trying to move the download from NewMars has something after the Fetch function finishes.

(th)

Offline

#95 2022-10-31 15:26:30

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,182

Re: Java (r) or Javascript Computer Language

For SpaceNut .... there ** is ** (apparently) another solution to the current hurdle I'm facing ....

Since console.log ** is ** able to deal with Fetch Promise situations (must wait for fulfillment before collecting data) there ** is ** (apparently) an option to direct console.log into a variable.

That would be a neat solution, if I can make it work.

***
We just came out of an extended Internet outage.

Things seem to be working now.

(th)

Offline

#96 2022-10-31 19:01:40

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,182

Re: Java (r) or Javascript Computer Language

For SpaceNut re edging forward in JavaScript sample ...

Length of result: 7485
20221031SampleHtmlJavascriptCORSVer02.htm:114 Show urlTestID http://newmars.com/forums/userlist.php? … estID12345
20221031SampleHtmlJavascriptCORSVer02.htm:115 Show if TestID found: TestID12345
20221031SampleHtmlJavascriptCORSVer02.htm:116 Show if Member Member
20221031SampleHtmlJavascriptCORSVer02.htm:117 Show location of match 2993
20221031SampleHtmlJavascriptCORSVer02.htm:118  next item is result
20221031SampleHtmlJavascriptCORSVer02.htm:119 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">

At the moment, I am experimenting with search methods while staying in the Fetch block, and using console.log for output.

The output above shows that the search functions work, but how they work is different (in some cases) from the documentation...

The first line shows the length of the result.
The second line shows the request sent to NewMars
The third line show that the TestID was found
The third line shows that the word Member was found
The fourth line shows where the word Member was found
The full result is then dumped to the log.

I'd like for this text to be moved into a variable that survives after the fetch is closed.

I've found suggestions to study, so will continue tomorrow.

Update a bit later:

The "match" method works differently than the documentation led me to expect .... I was expecting "true" or "false"

Instead, I'm seeing the word sought echoed back in the reply (eg, Member sought and Member found)

If the match does NOT succeed, I'm getting "null"

The program is working with the user table right now, because that does not require log in. 

I'm hoping you'll have proxy server problem worked out by the time I have the Fetch delivering data outside the Fetch block.

(th)

Offline

#97 2022-11-01 08:08:02

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,182

Re: Java (r) or Javascript Computer Language

For SpaceNut ....

While you are (hopefully) solving the Proxy problem, I am continuing to attempt to learn how to deal with asynchronous programming in JavaScript.

What I have established for certain is that console.log is able to deal with promises and deliveries from Fetch.  I decided to see if it is possible to collect data from console.log, since it is being saved by the browser at run time.

This source looks promising:

https://stackoverflow.com/questions/402 … hmtl5-page



Following two possible solutions.

01) As others have pointed out in comments, console.log() print always a result in browser console and not in the HTML of your page but you can change its behavior monkey patching (overwriting) the default console.log function provided by the browser, a really simple version could be:

console.log = function(message) {
    document.getElementById('result').innerHTML = message;
};
console.log('your result');
<div id="result"></div>

Join Stack Overflow to find the best answer to your technical question, help others answer theirs.

console.log = function(message) {
    document.getElementById('result').innerHTML = message;
};
console.log('your result');
<div id="result"></div>
Return to post

I've looked at numerous examples that look like that, but so far have not figured out how to make any of them work.

There is probably a ** really ** simple way to collect data that has been promised and delivered, but so far, all I'm collecting is the empty promise.

(th)

Offline

#98 2022-11-01 10:40:54

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,182

Re: Java (r) or Javascript Computer Language

For SpaceNut .... thanks to a generous contributor on one of the Stack forums, the sample program is delivering data from inside the Fetch block via console.log to the front page of the web form.

Run Status

Progress detail is to be reported here
Current ID is: 12345 After Fetch -
Current ID is: 12346 After Fetch -
Report from inside Fetch
Length of result: 7485
Show urlTestID http://newmars.com/forums/userlist.php? … estID12346
Show if TestID found: TestID12346
Show if Member Member
Show location of match 2993
This is from inside Fetch next item is result
Report from inside Fetch
Length of result: 7485
Show urlTestID http://newmars.com/forums/userlist.php? … estID12345
Show if TestID found: TestID12345
Show if Member Member
Show location of match 2993
This is from inside Fetch next item is result
This version ran on Edge on Windows 10

Development environment is Visual Studio Code

A curiosity is that while output from outside the form is in ascending order, output from inside Fetch is in descending order.

I am still a long way from knowing how to do this properly, at least the Promise is being partially fulfilled!

(th)

Offline

#99 2022-11-01 10:54:04

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,182

Re: Java (r) or Javascript Computer Language

For SpaceNut re TestID JavaScript ...

Here is the URL where you need to go to obtain permission to use demo proxy:
https://www.dropbox.com/s/lkyszobo9n3jd … o.txt?dl=0

Here is the latest version of the sample program, which writes to window.
https://www.dropbox.com/s/ap1ddrdb6xwe1 … 1.htm?dl=0

Anyone should be able to run this sample program, on any browser.

I'd appreciate feedback. The test does NOT require login to NewMars.

You can change the source code on your machine, to access other data.

Go to the demo site first, to obtain permission.

Permission is good for a day, and up to 50 tests.

Hopefully NewMars members will honor the generosity of the web site provider.

Please note that ** this ** version intercepts output to console.log, so nothing will show up in console.log if things work. I expect that errors will continue to show up in console.log, if there are any.

A typical error to expect is a decline from the Proxy server if you fail to ask permission.

I would ** also ** appreciate feedback on how to work with await properly. I am able to work with Fetch because console.log is smart enough to wait for data. At the moment, all I'm getting is the Promise of data, not the data itself.

(th)

Offline

#100 2022-11-01 13:30:30

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,182

Re: Java (r) or Javascript Computer Language

For SpaceNut re new JavaScript version ...

Here is the output from a run under Linux Ubuntu 22.04

Run Status

Progress detail is to be reported here
Current ID is: 12345 After Fetch -
Report from inside Fetch
Length of result: 7485
Show urlTestID http://newmars.com/forums/userlist.php? … estID12345
Show if TestID found: TestID12345
Show if Member Member
Show location of match 2993
This is from inside Fetch next item is result
This version ran on Edge on Windows 10

Development environment is Visual Studio Code

While I was outside raking, it occurred to me that the data delivered to the browser window ought to be accessible.

The question is ** when ** the information is accessible .... I'll investigate that tomorrow.

(th)

Offline

Board footer

Powered by FluxBB