Is there a way to fix the format with promises in VS Code?
when I format with prettier or any other options, the code look like this /
const GET_USERS = () => {
fetch('https://jsonplaceholder.typicode.com/todos/1').then((resolve) => {
resolve.json().then((json) => {
console.log(json);
});
});
};
and I really want that the code look like this /, without stop using prettier
const GET_USERS = () => {
fetch('https://jsonplaceholder.typicode.com/todos/1')
.then((resolve) => {resolve.json()
.then((json) => {console.log(json);
});
});
};
2
Answers
Try with this code:
Check how I’m chaining promises, one after another. Don’t forget to use a catch for errors. Also, maybe you are trying to return something from that function?
You can try like this: