如何在“ then”中为变量赋值?

时间:2020-01-30 15:38:51

标签: javascript ajax promise axios

    const testFunc = () => {
let test = [];
    axios
      .post('test.com', {
        filters: [
          {
            comparison: 'eq',
            fieldName: 'ID',
            fieldValue: `${id}`,
          },
        ],
      }).then(({ data }) => test = data);

return test;
}

我需要将在响应中得到的内容写入变量,但尝试这样做的结果是没有任何内容写入变量

0 个答案:

没有答案