Skip to content

Instantly share code, notes, and snippets.

const URL = 'https://rickandmortyapi.com/api/episode';
async function recursion(url) {
const response = await fetch(url);
const data = await response.json();
if (data && data.info && data.info.next) {
let d2 = await recursion(data.info.next);
return await [...data.results, ...d2];
}
return [...data.results];
@pzsprog
pzsprog / CorsListener.php
Last active March 31, 2020 20:58
Symfony CORS pre-flight kernel listener (with authorization)
<?php
// https://www.upbeatproductions.com/blog/cors-pre-flight-requests-and-headers-symfony-httpkernel-component
namespace App\EventListener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\Event\ResponseEvent;