phpc.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
A server for PHP programmers & friends. Join us for discussions on the PHP programming language, frameworks, packages, tools, open source, tech, life, and more.

Administered by:

Server stats:

800
active users

#fetchapi

1 post1 participant0 posts today
Inautilo<p><a href="https://mastodon.social/tags/Development" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Development</span></a> <a href="https://mastodon.social/tags/Explorations" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Explorations</span></a><br>Forbidden request headers · Some request headers are more trustworthy than others <a href="https://ilo.im/16333j" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://</span><span class="">ilo.im/16333j</span><span class="invisible"></span></a></p><p>_____<br><a href="https://mastodon.social/tags/Specification" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Specification</span></a> <a href="https://mastodon.social/tags/HttpHeaders" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>HttpHeaders</span></a> <a href="https://mastodon.social/tags/Browser" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Browser</span></a> <a href="https://mastodon.social/tags/JavaScript" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>JavaScript</span></a> <a href="https://mastodon.social/tags/FetchAPI" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>FetchAPI</span></a> <a href="https://mastodon.social/tags/XMLHttpRequest" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>XMLHttpRequest</span></a> <a href="https://mastodon.social/tags/CloudflareWorker" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>CloudflareWorker</span></a> <a href="https://mastodon.social/tags/WebDev" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>WebDev</span></a> <a href="https://mastodon.social/tags/Frontend" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Frontend</span></a> <a href="https://mastodon.social/tags/Backend" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Backend</span></a></p>
Nebyoolae<p>Regarding the latest episode (049) of the <a href="https://masto.neb.host/tags/HackingTheGrepson" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>HackingTheGrepson</span></a> podcast, I decided to make a more full-featured solution using the <a href="https://masto.neb.host/tags/FetchAPI" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>FetchAPI</span></a>. I now know how to pull puzzle input directly from the <a href="https://masto.neb.host/tags/adventofcode" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>adventofcode</span></a> site, which is pretty cool.</p><p><a href="https://carbon.now.sh/?bg=rgba%2874%2C144%2C226%2C1%29&amp;t=material&amp;wt=none&amp;l=auto&amp;width=871&amp;ds=true&amp;dsyoff=20px&amp;dsblur=68px&amp;wc=true&amp;wa=false&amp;pv=56px&amp;ph=50px&amp;ln=false&amp;fl=1&amp;fm=Fira+Code&amp;fs=14px&amp;lh=152%25&amp;si=false&amp;es=2x&amp;wm=false&amp;code=%252F%252F%2520AOC%25202019%253A%2520Day%25201%253A%2520The%2520Tyranny%2520of%2520the%2520Rocket%2520Equation%250A%250Alet%2520example_input_part_1%2520%253D%25200%250Alet%2520puzzle_input_part_1%2520%2520%253D%25200%250Alet%2520example_input_part_2%2520%253D%25200%250Alet%2520puzzle_input_part_2%2520%2520%253D%25200%250A%250Aasync%2520function%2520getAocInput%28%29%2520%257B%250A%2520%2520const%2520options%2520%253D%2520%257B%250A%2520%2520%2520%2520method%253A%2520%27GET%27%252C%250A%2520%2520%2520%2520headers%253A%2520%257B%250A%2520%2520%2520%2520%2520%2520cookie%253A%2520%2560session%253D%2524%257Bprocess.env.AOC_SESSION_TOKEN%257D%2560%250A%2520%2520%2520%2520%257D%250A%2520%2520%257D%253B%250A%250A%2520%2520return%2520fetch%28%27https%253A%252F%252Fadventofcode.com%252F2019%252Fday%252F1%252Finput%27%252C%2520options%29%250A%2520%2520%2520%2520.then%28response%2520%253D%253E%2520response.text%28%29%29%250A%2520%2520%2520%2520.then%28inputs%2520%253D%253E%2520inputs%29%250A%2520%2520%2520%2520.catch%28err%2520%253D%253E%2520console.error%28err%29%29%253B%250A%257D%250A%250Afunction%2520getFuel%28input%252C%2520should_recurse%29%2520%257B%250A%2520%2520let%2520fuel%2520%253D%2520Math.floor%28input%2520%252F%25203%29%2520-%25202%250A%250A%2520%2520if%2520%28fuel%2520%253C%253D%25200%29%2520%257B%250A%2520%2520%2520%2520return%25200%250A%2520%2520%257D%250A%250A%2520%2520%252F%252F%2520Part%25202%250A%2520%2520if%2520%28fuel%2520%253E%25200%2520%2526%2526%2520should_recurse%29%2520%257B%250A%2520%2520%2520%2520return%2520fuel%2520%252B%253D%2520getFuel%28fuel%252C%2520should_recurse%29%250A%2520%2520%257D%250A%250A%2520%2520%252F%252F%2520Part%25201%2520and%2520Part%25202%250A%2520%2520return%2520fuel%250A%257D%250A%250A%253B%28async%28%29%2520%253D%253E%2520%257B%250A%2520%2520%252F%252F%2520Part%25201%250A%2520%2520const%2520example_inputs%2520%253D%2520%255B12%252C%252014%252C%25201969%252C%2520100756%255D%250A%250A%2520%2520example_inputs.forEach%28input%2520%253D%253E%2520%257B%250A%2520%2520%2520%2520example_input_part_1%2520%252B%253D%2520getFuel%28input%252C%2520false%29%250A%2520%2520%257D%29%250A%250A%2520%2520console.log%28%2560Example%2520Input%2520Part%25201%253A%2520%2524%257Bexample_input_part_1%257D%2560%29%250A%250A%2520%2520const%2520aoc_result%2520%253D%2520await%2520getAocInput%28%29%250A%250A%2520%2520if%2520%28aoc_result%29%2520%257B%250A%2520%2520%2520%2520const%2520test_inputs%2520%253D%2520aoc_result.split%28%27%255Cn%27%29%250A%250A%2520%2520%2520%2520test_inputs.forEach%28input%2520%253D%253E%2520%257B%250A%2520%2520%2520%2520%2520%2520puzzle_input_part_1%2520%252B%253D%2520getFuel%28input%252C%2520false%29%250A%2520%2520%2520%2520%257D%29%250A%250A%2520%2520%2520%2520console.log%28%2560Puzzle%2520Input%2520Part%25201%253A%2520%2524%257Bpuzzle_input_part_1%257D%2560%29%250A%250A%2520%2520%2520%2520%252F%252F%2520Part%25202%250A%2520%2520%2520%2520example_inputs.forEach%28input%2520%253D%253E%2520%257B%250A%2520%2520%2520%2520%2520%2520example_input_part_2%2520%252B%253D%2520getFuel%28input%252C%2520true%29%250A%2520%2520%2520%2520%257D%29%250A%250A%2520%2520%2520%2520console.log%28%2560Example%2520Input%2520Part%25202%253A%2520%2524%257Bexample_input_part_2%257D%2560%29%250A%250A%2520%2520%2520%2520test_inputs.forEach%28input%2520%253D%253E%2520%257B%250A%2520%2520%2520%2520%2520%2520puzzle_input_part_2%2520%252B%253D%2520getFuel%28input%252C%2520true%29%250A%2520%2520%2520%2520%257D%29%250A%250A%2520%2520%2520%2520console.log%28%2560Puzzle%2520Input%2520Part%25202%253A%2520%2524%257Bpuzzle_input_part_2%257D%2560%29%250A%2520%2520%257D%2520else%2520%257B%250A%2520%2520%2520%2520console.error%28%27could%2520not%2520fetch%2520test_inputs%27%29%250A%2520%2520%257D%250A%257D%29%28%29" rel="nofollow noopener noreferrer" target="_blank"><span class="invisible">https://</span><span class="ellipsis">carbon.now.sh/?bg=rgba%2874%2C</span><span class="invisible">144%2C226%2C1%29&amp;t=material&amp;wt=none&amp;l=auto&amp;width=871&amp;ds=true&amp;dsyoff=20px&amp;dsblur=68px&amp;wc=true&amp;wa=false&amp;pv=56px&amp;ph=50px&amp;ln=false&amp;fl=1&amp;fm=Fira+Code&amp;fs=14px&amp;lh=152%25&amp;si=false&amp;es=2x&amp;wm=false&amp;code=%252F%252F%2520AOC%25202019%253A%2520Day%25201%253A%2520The%2520Tyranny%2520of%2520the%2520Rocket%2520Equation%250A%250Alet%2520example_input_part_1%2520%253D%25200%250Alet%2520puzzle_input_part_1%2520%2520%253D%25200%250Alet%2520example_input_part_2%2520%253D%25200%250Alet%2520puzzle_input_part_2%2520%2520%253D%25200%250A%250Aasync%2520function%2520getAocInput%28%29%2520%257B%250A%2520%2520const%2520options%2520%253D%2520%257B%250A%2520%2520%2520%2520method%253A%2520%27GET%27%252C%250A%2520%2520%2520%2520headers%253A%2520%257B%250A%2520%2520%2520%2520%2520%2520cookie%253A%2520%2560session%253D%2524%257Bprocess.env.AOC_SESSION_TOKEN%257D%2560%250A%2520%2520%2520%2520%257D%250A%2520%2520%257D%253B%250A%250A%2520%2520return%2520fetch%28%27https%253A%252F%252Fadventofcode.com%252F2019%252Fday%252F1%252Finput%27%252C%2520options%29%250A%2520%2520%2520%2520.then%28response%2520%253D%253E%2520response.text%28%29%29%250A%2520%2520%2520%2520.then%28inputs%2520%253D%253E%2520inputs%29%250A%2520%2520%2520%2520.catch%28err%2520%253D%253E%2520console.error%28err%29%29%253B%250A%257D%250A%250Afunction%2520getFuel%28input%252C%2520should_recurse%29%2520%257B%250A%2520%2520let%2520fuel%2520%253D%2520Math.floor%28input%2520%252F%25203%29%2520-%25202%250A%250A%2520%2520if%2520%28fuel%2520%253C%253D%25200%29%2520%257B%250A%2520%2520%2520%2520return%25200%250A%2520%2520%257D%250A%250A%2520%2520%252F%252F%2520Part%25202%250A%2520%2520if%2520%28fuel%2520%253E%25200%2520%2526%2526%2520should_recurse%29%2520%257B%250A%2520%2520%2520%2520return%2520fuel%2520%252B%253D%2520getFuel%28fuel%252C%2520should_recurse%29%250A%2520%2520%257D%250A%250A%2520%2520%252F%252F%2520Part%25201%2520and%2520Part%25202%250A%2520%2520return%2520fuel%250A%257D%250A%250A%253B%28async%28%29%2520%253D%253E%2520%257B%250A%2520%2520%252F%252F%2520Part%25201%250A%2520%2520const%2520example_inputs%2520%253D%2520%255B12%252C%252014%252C%25201969%252C%2520100756%255D%250A%250A%2520%2520example_inputs.forEach%28input%2520%253D%253E%2520%257B%250A%2520%2520%2520%2520example_input_part_1%2520%252B%253D%2520getFuel%28input%252C%2520false%29%250A%2520%2520%257D%29%250A%250A%2520%2520console.log%28%2560Example%2520Input%2520Part%25201%253A%2520%2524%257Bexample_input_part_1%257D%2560%29%250A%250A%2520%2520const%2520aoc_result%2520%253D%2520await%2520getAocInput%28%29%250A%250A%2520%2520if%2520%28aoc_result%29%2520%257B%250A%2520%2520%2520%2520const%2520test_inputs%2520%253D%2520aoc_result.split%28%27%255Cn%27%29%250A%250A%2520%2520%2520%2520test_inputs.forEach%28input%2520%253D%253E%2520%257B%250A%2520%2520%2520%2520%2520%2520puzzle_input_part_1%2520%252B%253D%2520getFuel%28input%252C%2520false%29%250A%2520%2520%2520%2520%257D%29%250A%250A%2520%2520%2520%2520console.log%28%2560Puzzle%2520Input%2520Part%25201%253A%2520%2524%257Bpuzzle_input_part_1%257D%2560%29%250A%250A%2520%2520%2520%2520%252F%252F%2520Part%25202%250A%2520%2520%2520%2520example_inputs.forEach%28input%2520%253D%253E%2520%257B%250A%2520%2520%2520%2520%2520%2520example_input_part_2%2520%252B%253D%2520getFuel%28input%252C%2520true%29%250A%2520%2520%2520%2520%257D%29%250A%250A%2520%2520%2520%2520console.log%28%2560Example%2520Input%2520Part%25202%253A%2520%2524%257Bexample_input_part_2%257D%2560%29%250A%250A%2520%2520%2520%2520test_inputs.forEach%28input%2520%253D%253E%2520%257B%250A%2520%2520%2520%2520%2520%2520puzzle_input_part_2%2520%252B%253D%2520getFuel%28input%252C%2520true%29%250A%2520%2520%2520%2520%257D%29%250A%250A%2520%2520%2520%2520console.log%28%2560Puzzle%2520Input%2520Part%25202%253A%2520%2524%257Bpuzzle_input_part_2%257D%2560%29%250A%2520%2520%257D%2520else%2520%257B%250A%2520%2520%2520%2520console.error%28%27could%2520not%2520fetch%2520test_inputs%27%29%250A%2520%2520%257D%250A%257D%29%28%29</span></a></p>