You can simply rewrite your code to use async/await
:
const response = await fetch("fileName");
const data = await response.json();
const date = data.JSONdata[data.JSONdata.length - 1].date;
const prices = data.JSONdata[data.JSONdata.length - 1].prices;
EDIT: To use this asynchronous code, you have to define the function in which you use this code as async:
async function yourFunction() {
// your async code from above
}
// await async function where it's called
const functionResult = await yourFunction();
You have to make every function in your callstack async up to the level where you no longer care about the response. So the function which calls "yourFunction()" has to be async aswell. And so on.