You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
972 B
34 lines
972 B
class ApiService{
|
|
constructor(){}
|
|
async get(link){
|
|
const baseUrl = `${link}`;//edit
|
|
const headers = {
|
|
method: 'GET'
|
|
};
|
|
let response = await fetch(baseUrl, headers);
|
|
console.log("response",response)
|
|
let responseJson = await response.json()
|
|
console.log("responseJson",responseJson)
|
|
return responseJson;
|
|
}
|
|
async post(link){
|
|
const baseUrl = `${link}`;//edit
|
|
const headers = {
|
|
method: 'POST',
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({
|
|
word:"yessss"
|
|
})
|
|
};
|
|
fetch(baseUrl, headers).then( (response) => {
|
|
if (response.ok)
|
|
console.log("Posted")
|
|
else
|
|
throw new Error('Une erreur est survenue durant l\'appel HTTP.');
|
|
})
|
|
}
|
|
}
|