Why does this code compile perfectly?
fetch('someurl', {
method: 'GET',
credentials:"same-origin"
})
However, the following code throws a compilation error for fetch('someurl', init);
const init = {
method: 'GET',
credentials: "same-origin"
};
fetch('someurl', init);
What could be the reason behind this discrepancy?
Explore the code here