Created
December 5, 2018 13:08
-
-
Save beaucarnes/41834a14c92ecf9fb2e4128d4c25e207 to your computer and use it in GitHub Desktop.
Add casts to playlist in Scrimba.
This file contains 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
const fetch = require('node-fetch'); | |
var scimbaList = [ | |
["cJkqwhd", "Import a Default Export"], | |
["cnVnkhZ", "Create an Export Fallback with export default"], | |
["cLDNvhP", "Use * to Import Everything from a File"], | |
["cggGNub", "Use export to Reuse a Code Block"], | |
["cBWq6T9", "Understand the Differences Between import and require"], | |
["cWpbKHb", "Use getters and setters to Control Access to an Object"], | |
["cG7W6T6", "Use class Syntax to Define a Constructor Function"], | |
["cnV3yup", "Write Concise Declarative Functions with ES6"], | |
["czgpKH3", "Write Concise Object Literal Declarations Using Simple Fields"], | |
["cwLQ7Hn", "Create Strings using Template Literals"], | |
["cwLQQSJ", "Use Destructuring Assignment to Pass an Object as a Function's"], | |
["cV2rvCW", "Use Destructuring Assignment with the Rest Operator to Reassign Array"], | |
["cWpWKhb", "Use Destructuring Assignment to Assign Variables from Arrays"], | |
["cP4DMCZ", "Use Destructuring Assignment to Assign Variables from Nested"], | |
["cnVZVHE", "Use Destructuring Assignment to Assign Variables from Objects"], | |
["c96Pyuy", "Use the Spread Operator to Evaluate Arrays In-Place"], | |
["c3JpMta", "Use the Rest Operator with Function Parameters"], | |
["cm8LPAM", "Set Default Parameters for Your Functions"], | |
["ck4L6T9", "Write Higher Order Arrow Functions"], | |
["cnQLGf9", "Write Arrow Functions with Parameters"], | |
["cZeLdsL", "Use Arrow Functions to Write Concise Anonymous Functions"], | |
["cLe2ph6", "Prevent Object Mutation"], | |
["c9yvPHR", "Mutate an Array Declared with const"], | |
["cekLnAN", "Declare a Read-Only Variable with the const Keyword"], | |
["cLez8TE", "Compare Scopes of the var and let Keywords"], | |
] | |
let playlistID = "p7v3gCd" | |
let scrimbas = ""; | |
for (scrim of scimbaList.reverse()) { | |
scrimbas += `"${scrim[0]}", `; | |
} | |
scrimbas = scrimbas.slice(0, -2) | |
addToPlaylist(playlistID, scrimbas); | |
function addToPlaylist(playlistID, scrimbas) { | |
fetch("https://scrimba.com/rpc/playlistAddItems", { | |
credentials: "include", | |
headers: { | |
accept: "*/*", | |
"accept-language": "en-US,en;q=0.9", | |
"content-type": "application/json", | |
"scrimba-client-version": "dc5761ebaec4b0ca0e34" | |
}, | |
referrer: "https://scrimba.com/ux7kQtZ", | |
referrerPolicy: "no-referrer-when-downgrade", | |
body: | |
'{"name":"playlistAddItems","args":["' + playlistID + '",[' + scrimbas + ']],"options":{}}', | |
method: "POST", | |
mode: "cors" | |
}). | |
then(response => { | |
console.log(response); | |
if (response.ok) { | |
return response.json() | |
} else { | |
return Promise.reject('something went wrong!') | |
} | |
}) | |
.then(data => console.log('data is', data)) | |
.catch(error => console.log('error is', error)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment