-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
69 additions
and
5 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import axios from 'axios'; | ||
|
||
async function postRecomendations(id) { | ||
const body = { | ||
id: id | ||
}; | ||
const response = await axios.post(`https://nodecraft.me/recommendations/`, body); | ||
return response.data; | ||
} | ||
|
||
async function getRecomendations(id) { | ||
const response = await axios.get(`https://nodecraft.me/recommendations/${id}`); | ||
return response.data; | ||
} | ||
|
||
async function Recommendations(data) { | ||
const fixtures = data.result; | ||
const requests = fixtures.map(async (fixture) => { | ||
const response = await axios.get(`https://nodecraft.me/fixtures/${fixture}`); | ||
// Do something with the response | ||
return response.data; // Return the response data if needed | ||
}); | ||
|
||
const responses = await Promise.all(requests); | ||
return responses; | ||
} | ||
|
||
async function getHistory(id) { | ||
const response = await axios.get(`https://nodecraft.me/recommendations/${id}/history`); | ||
const filteredData = response.data.filter(item => item.response != {}); | ||
console.log(filteredData); | ||
return filteredData; | ||
} | ||
|
||
async function madeRecommendations(id) { | ||
const job = await postRecomendations(id); | ||
const data = await getRecomendations(id); | ||
const result = await Recommendations(data); | ||
return result; | ||
} | ||
|
||
|
||
//console.log(await Recommendations(fixtures)); | ||
|
||
|
||
|
||
export { | ||
getHistory, | ||
madeRecommendations | ||
}; |