#react api

14 messages · Page 1 of 1 (latest)

nimble adder
peak hamlet
#

Check the course, they might have an updated link to fetch the data from.

nimble adder
peak hamlet
#

Either the link is wrong or its not the API link anymore. 404 error = removed/deleted
You should check with the course and ask for an updated link.

nimble adder
#

o prepare for the completion of this exercise, you need to include the API JavaScript file in your code.

Add the following code to your index.html.

1
<script src="https://raw.githubusercontent.com/Meta-Front-End-Developer-PC/capstone/master/api.js"></script>
The API has two functions that you can use in your code:

fetchAPI(date) - This function accepts a date as a parameter and returns an array of available reservation times for the provided date

submitAPI(formData) - This function accepts the booking form data as a parameter and will return true if the data was successfully submitted.

#

these are the instructions

peak hamlet
nimble adder
#

the question im about to ask might look stupid , like how did this data come from ???????? const seededRandom = function (seed) {
var m = 2 ** 35 - 31;
var a = 185852;
var s = seed % m;
return function () {
return (s = (s * a) % m) / m;
};
};

export function fetchAPI(date) {
let result = [];
let dt = new Date(date);
let seed = dt.getDate();

let random = seededRandom(seed);
for (let i = 17; i <= 23; i++) {
if (random() < 0.5) {
result.push(i + ":00");
}
if (random() < 0.5) {
result.push(i + ":30");
}
}
return result;
}

export function submitAPI(formData) {
return true;
}

peak hamlet
#

they created a fake API call, which returns random data.

nimble adder
#

I am really stuck right now ?? can u explain?

#

how did they creat a fake API call?

peak hamlet
#

The link provided by the course is broken, they might have moved it somewhere else. You should request your peers(they might have a common community or discussion board) to get an updated link.
And I think even the updated link will provide the same thing that this file returns.

peak hamlet
#

If its really confusing at this point, you should ask someone in that community (coursera?) to provide the updated link. If you could just tell them it giving 404 error, they will know what to do.