Skip to content

Instantly share code, notes, and snippets.

@zacjones93
Created October 23, 2023 16:08
Show Gist options
  • Save zacjones93/d1ccc1f2d1b6c3865d8234d5ead68549 to your computer and use it in GitHub Desktop.
Save zacjones93/d1ccc1f2d1b6c3865d8234d5ead68549 to your computer and use it in GitHub Desktop.
// Name: rails set lesson tag
// Author: Zac Jones
// Keyword: rt
import "@johnlindquist/kit"
const tagName = await arg("Enter tag name: ")
const token = await env("EGGHEAD_AUTH_TOKEN")
let lessonUrl = await getActiveTab()
let lessonSlug = lessonUrl.split("/").pop().split("?")[0]
const url = `https://app.egghead.io/api/v1/lessons/${lessonSlug}`;
const headers = {
'Authorization': `Bearer ${token}`
};
const body = new FormData();
body.append('lesson[topic_list]', tagName);
fetch(url, {
method: 'PUT',
headers,
body
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment