Skip to content

getFile sometimes returns an object for Dropbox. #1185

@kevincox

Description

@kevincox

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/

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions