fetch(fileURL, doAutoAuth = true)

The pods:fetch() function returns the file at the specified URL, fileURL, from the connected pod. The file is returned as a string in the form of a data scheme. If the file does not exist, the function returns a null. pods:connectStorage() should be called at some point prior to using this function (pods:connectStorage() does not need to be called again if the pico engine is restarted).

The pods:fetch() function has the following parameters:

  • fileURL — A required string parameter that informs the library where the file to be fetched exists inside the pod. This should be a full, absolute URL with an http scheme (e.g. http://examplepodserver.org/podName/container/file.txt).

  • doAutoAuth — An optional boolean parameter that controls automatic authentication attempts. It defaults to true if nothing is passed in for it. When true, the library will check that the stored authentication token is valid if it exists, and if the token is not valid or the token does not exist, the library will attempt to automatically authenticate once.

Copyright Picolabs | Licensed under Creative Commons.