-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconect.js
More file actions
37 lines (29 loc) · 1001 Bytes
/
conect.js
File metadata and controls
37 lines (29 loc) · 1001 Bytes
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
const apiOne = "https://interactive-rating-component-f0os.onrender.com/avaliacao";
const apiTwoPost = "https://interactive-rating-api.onrender.com/rating";
const apiTwo = "https://interactive-rating-api.onrender.com/getRanking";
async function postAvaliation(body) {
const conexao = await fetch(apiOne, {
method: 'POST',
headers: {
'content-type': 'application/json'
},
body: JSON.stringify(body)
})
// ApiOne
localStorage.setItem("avaliation", body.avaliacao);
localStorage.setItem("user", body.nome);
//ApiTwo
// localStorage.setItem("avaliation", body.value);
// localStorage.setItem("user", body.name);
const conexaoConvertida = await conexao.json();
return conexaoConvertida;
}
async function getAvaliations() {
const conexao = await fetch(apiOne);
const conexaoConvertida = await conexao.json();
return conexaoConvertida;
}
export const conectApi = {
postAvaliation,
getAvaliations
}