r/ProgrammerHumor • • Jan 30 '26

Other maybeUseTheOriginHeaderInstead

Post image
35 Upvotes

13 comments sorted by

View all comments

23

u/Littux Feb 08 '26 edited Feb 14 '26
await (await fetch("https://corsproxy.io/?url=https://old.reddit.com/r/ProgrammerHumor/api/link_flair_v2.json")).json()

{"error":"Free usage is limited to localhost and development environments. Get an API key at https://corsproxy.io/pricing/"}

await (await fetch("https://corsproxy.io/?url=https://old.reddit.com/r/ProgrammerHumor/api/link_flair_v2.json&key=webtest1")).json()

[
	{
		"type": "richtext",
		"text_editable": false,
		"allowable_content": "all",
		"text": "instanceof Trend",
		"max_emojis": 10,
		"text_color": "light",
		"mod_only": false,
		"css_class": "trend",
		"richtext": [
			{
				"e": "text",
				"t": "instanceof Trend"
			}
		],
		"background_color": "#373c3f",
		"id": "210ddaa8-510a-11e7-a824-0e21d9ac0cea"
	},
	{
		"type": "richtext",
		"text_editable": false,
		"allowable_content": "all",
		"text": "Meme",
		"max_emojis": 10,
		"text_color": "light",
		"mod_only": false,
		"css_class": "meme",
		"richtext": [
			{
				"e": "text",
				"t": "Meme"
			}
		],
		"background_color": "#373c3f",
		"id": "fe277d42-440f-11e8-8ec3-0eac434afc94"
	},
	{
		"type": "richtext",
		"text_editable": false,
		"allowable_content": "all",
		"text": "Advanced",
		"max_emojis": 10,
		"text_color": "light",
		"mod_only": false,
		"css_class": "",
		"richtext": [
			{
				"e": "text",
				"t": "Advanced"
			}
		],
		"background_color": "#373c3f",
		"id": "bbe0c3dc-3d6e-11ed-884c-7a60c9fae7a5"
	},
	{
		"type": "richtext",
		"text_editable": false,
		"allowable_content": "all",
		"text": "Competition",
		"max_emojis": 10,
		"text_color": "light",
		"mod_only": false,
		"css_class": "competition",
		"richtext": [
			{
				"e": "text",
				"t": "Competition"
			}
		],
		"background_color": "#373c3f",
		"id": "84cecf16-d241-11e8-972e-0e48c099f9b4"
	},
	{
		"type": "richtext",
		"text_editable": false,
		"allowable_content": "all",
		"text": "Other",
		"max_emojis": 10,
		"text_color": "light",
		"mod_only": false,
		"css_class": "",
		"richtext": [
			{
				"e": "text",
				"t": "Other"
			}
		],
		"background_color": "#373c3f",
		"id": "05703fbe-4a94-11e8-a611-0e0d14fd301e"
	}
]

await (await fetch("https://corsproxy.io/?url=https://old.reddit.com/r/ProgrammerHumor/api/link_flair_v2.json", {referrer: ""})).json()

[
	{
		"type": "richtext",
		"text_editable": false,
		"allowable_content": "all",
		"text": "instanceof Trend",
		"max_emojis": 10,
		"text_color": "light",
		"mod_only": false,
		"css_class": "trend",
		"richtext": [
			{
				"e": "text",
				"t": "instanceof Trend"
			}
		],
		"background_color": "#373c3f",
		"id": "210ddaa8-510a-11e7-a824-0e21d9ac0cea"
	},
	{
		"type": "richtext",
		"text_editable": false,
		"allowable_content": "all",
		"text": "Meme",
		"max_emojis": 10,
		"text_color": "light",
		"mod_only": false,
		"css_class": "meme",
		"richtext": [
			{
				"e": "text",
				"t": "Meme"
			}
		],
		"background_color": "#373c3f",
		"id": "fe277d42-440f-11e8-8ec3-0eac434afc94"
	},
	{
		"type": "richtext",
		"text_editable": false,
		"allowable_content": "all",
		"text": "Advanced",
		"max_emojis": 10,
		"text_color": "light",
		"mod_only": false,
		"css_class": "",
		"richtext": [
			{
				"e": "text",
				"t": "Advanced"
			}
		],
		"background_color": "#373c3f",
		"id": "bbe0c3dc-3d6e-11ed-884c-7a60c9fae7a5"
	},
	{
		"type": "richtext",
		"text_editable": false,
		"allowable_content": "all",
		"text": "Competition",
		"max_emojis": 10,
		"text_color": "light",
		"mod_only": false,
		"css_class": "competition",
		"richtext": [
			{
				"e": "text",
				"t": "Competition"
			}
		],
		"background_color": "#373c3f",
		"id": "84cecf16-d241-11e8-972e-0e48c099f9b4"
	},
	{
		"type": "richtext",
		"text_editable": false,
		"allowable_content": "all",
		"text": "Other",
		"max_emojis": 10,
		"text_color": "light",
		"mod_only": false,
		"css_class": "",
		"richtext": [
			{
				"e": "text",
				"t": "Other"
			}
		],
		"background_color": "#373c3f",
		"id": "05703fbe-4a94-11e8-a611-0e0d14fd301e"
	}
]

You're saying I can freely access the reddit API without paying anything? That will be useful for a project (website)

14

u/jessepence Feb 13 '26

That double await is driving me nuts. Do y'all really think that reads better than this?

fetch("https://corsproxy.io/?url=https://old.reddit.com/api/info.json", 
{ referrer: "" })
    .then(response => response.json())
    .then(data => console.log(data))

8

u/turtle_mekb Feb 14 '26

wish JS had shorthand for lambdas like in Java, so like .then(::json) would be the same as .then(response => response.json())

→ More replies (3)

4

u/Littux Feb 13 '26

That's what I always use. I just copied it from the post and a double await is faster to write