Created
October 23, 2023 16:08
-
-
Save zacjones93/d1ccc1f2d1b6c3865d8234d5ead68549 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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