这个错误通常发生在使用Unsplash API的时候,因为请求中的client_id参数未定义或无效。要解决这个问题,需要以下步骤:
确认请求中的client_id参数是否正确。client_id是在Unsplash注册账号后获得的Access Key,如果没有授权或使用无效的key,将无法获得API的授权。
在代码中定义client_id参数,例如:
const clientId = "your_access_key";
const apiURL = https://api.unsplash.com/photos/?client_id=${clientId}
;
在这个代码示例中,将Access Key赋值给变量clientId,然后使用字符串插值的方式将其传递给请求URL中的参数。
通过以上步骤,可以修复“bundle.js:102 GET https://api.unsplash.com/photos?client_id=undefined 401”错误并正常使用Unsplash API。