Query: failed to construct ‘blob’: the provided value cannot be converted to a sequence.
This error message usually occurs when trying to construct a Blob object with an invalid or unsupported value. A Blob represents immutable raw data.
The Blob constructor takes an array of ArrayBuffer, ArrayBufferView, a Blob, or a string as the value parameter. If the provided value cannot be converted to a sequence (ArrayBuffer, ArrayBufferView, or string), this error is thrown.
Let’s see some examples to better understand the error:
Example 1:
const invalidValue = null;
const blob = new Blob([invalidValue]); // throws 'failed to construct 'blob': the provided value cannot be converted to a sequence.'
In this example, we’re passing null as the value. Since null is not a valid parameter for constructing a Blob, the error is thrown.
Example 2:
const unsupportedValue = { foo: 'bar' };
const blob = new Blob([unsupportedValue]); // throws 'failed to construct 'blob': the provided value cannot be converted to a sequence.'
Here, we’re passing an object ({ foo: ‘bar’ }) as the value. Only ArrayBuffer, ArrayBufferView, Blob, or string are supported values. Since the provided value is not a valid type, the error is thrown.
To fix this error, make sure you’re passing a valid value that can be converted to a sequence (ArrayBuffer, ArrayBufferView, or string) to the Blob constructor.