Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getFile sometimes returns an object for Dropbox. #1185

Open
kevincox opened this issue Jun 16, 2020 · 0 comments
Open

getFile sometimes returns an object for Dropbox. #1185

kevincox opened this issue Jun 16, 2020 · 0 comments

Comments

@kevincox
Copy link
Contributor

There appears to be an issue where getFile retrieves and object from the Dropbox API it returns an object instead of a string. This does not appear to happen if the result is loaded from the cache.

This appears to be a bug because according to the docs "A file is raw data, as opposed to a JSON object"

Response from cache:

{
  "data": "{\"title\":\"New Recipe2\",\"servings\":4,\"ingredients\":[],\"steps\":[{\"instruction\":\"No steps.\"}]}",
  "contentType": "application/json"
}

Response from Dropbox API:

{
  "data": {
    "title": "New Recipe2",
    "servings": 4,
    "ingredients": [],
    "steps": [
      {
        "instruction": "No steps."
      }
    ]
  },
  "contentType": "application/json; charset=UTF-8"
}

Example code with workaround: https://gitlab.com/kevincox/recipes/-/blob/5b8b92be2e1ecadab45267a320abc619b4f776cb/src/db.js#L27-34

You can see it live at the following URL (for now, can't provide a permalink due to API token URL restrictions). Try creating a recipe and saving. The page reloads the recipe (usually from cache) and the logged response is a string. If you reload the page it will come from the server and log an already-parsed object. https://recipes.kevincox.ca/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants