-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
39 lines (36 loc) · 1.33 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'use strict'
; (function () {
// Need add Authorization value from headers after login
const bearer = '[Authorization headers value]'
const headers = new Headers()
headers.append('Authorization', bearer)
/**
* @type RequestInit
*/
const init = {
method: 'GET',
headers: headers,
mode: 'cors',
cache: 'default'
}
const url = 'https://cookidoo.pl/vorwerkApiV2/apiv2/browseRecipe?limit=1455'
fetch(url, init)
.then(response => {
return response.text()
})
.then(text => {
const jsonObj = JSON.parse(text)
const data = _.map(jsonObj.content, (elem) => {
const selfLink = _.find(elem.links, (e) => e.rel === 'self')
const id = selfLink.href.match(/[0-9]+$/)[0]
const link = `https://cookidoo.pl/vorwerkWebapp/app#/recipe/${id}`
return { name: elem.name, link: link }
})
// @TODO: copy to clipboard
const body = document.querySelector('body')
body.textContent = JSON.stringify(data, null, 4)
})
.catch(err => {
console.error(err)
})
})()