MusixMatch API即使与API密钥一起使用也返回401

问题描述

我正试图通过MusixMatch API吸引艺术家。我正在通过musicmatch NPM package访问API。我已经导入了程序包,并将其API密钥输入如下:

const music = require("musicmatch")({ apikey: process.env.API_KEY });

API密钥在我的.env文件中。然后,我尝试通过搜索艺术家的ID来访问它(请注意:ArtistID是我目前在代码中已经拥有的东西,并且它是合法的artist_id)。

music
  .artist({ artist_id: artistID })
  .then(function (data: any) {
    console.log(data.message);
    //res.send(data);
  })
  .catch(function (err: any) {
    console.log(err);
  });

我得到的答复是:

{ header: { status_code: 401,execute_time: 0.00039291381835938 },body: [] }

有什么想法即使我正在使用API​​密钥也为什么会得到401?

以下是与artist.get有关的MusixMatch文档。

编辑:当我将实际的API_KEY字符串添加到musicmatch require时,API调用成功完成,并且得到响应。但是,当我从.env文件提取API_KEY时,它仍然失败。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)