I am having trouble with the following function:

```
function archive_email() {
  let emailID = localStorage.emailID.toString();
  let emailid = '/emails/' + emailID;

  // Use Fetch to update database, archiving this email.
  fetch(emailid, {
    method: 'PUT',
    body: JSON.stringify({
      archived: true
    })
  })
  load_inbox();
}

```

This is for a class, where I am making a basic email client and server.

The code above is called from a button being pushed, that has its own listening handler. As is, it works as expected: when the button is pushed it sets a boolean in a sqllite DB, and then runs the function load\_inbox(). The trouble is that the load\_inbox () is running too soon, as it is not supposed to show any emails with the archived tagged but they are showing up on the load\_inbox() call. If I refresh the page, they then vanish as they should. I have tried to wait for the promise return, like this:

```
function archive_email() {
  let emailID = localStorage.emailID.toString();
  let emailid = '/emails/' + emailID;

  // Use Fetch to update database, archiving this email.
  fetch(emailid, {
    method: 'PUT',
    body: JSON.stringify({
      archived: true
    })
  })
  .then(response => response.json())
  .then(result => {
    // Print result
    console.log(result);
});
  load_inbox();
}

```

However, I get the following error with the above:

> 
> Uncaught (in promise) SyntaxError: Unexpected end of JSON input
> at inbox.js:327
> 
> 
> 

Line 327 is the .then line I inserted above:

```
.then(response => response.json())

```

Does anyone have any suggestions on how to make this work?
Thank you for your time.