The conversation between human and AI assistant.
What are Promises in Javascript?
Can you give me an example of how to use a Promise?
Of course! Here's an example: 

```
const fetchData = () => {
    return new Promise((resolve, reject) => {
        fetch('https://jsonplaceholder.typicode.com/todos/1')
            .then(response => response.json())
            .then(data => {
                resolve(data);
            })
            .catch(error => {
                reject(error);
            });
    });
}

fetchData().then(data => {
    console.log(data);
}).catch(error => {
    console.log(error);
});
```

This code uses the Fetch API to make a request to a dummy endpoint, and then returns a Promise with the data from that request. The Promise is then handled with `.then()` and `.catch()` methods, depending on if it was resolved or rejected.