Octopus Energy interview question

Use this API to write a TypeScript function with error handling etc