变量在调试器中显示为“未定义”

时间:2019-09-06 14:57:36

标签: javascript jquery http promise axios

我正在尝试使用axios,promise和其他ES6功能显示数据。该项目可在产品中运行,但是在开发环境中更改API端点(不再使用旧端点)后,我遇到了问题。

由于某种原因,我正在使用的变量(kkUser)出现为undefined。我不确定这是否与其他端点有关。

帮助文件:

const kkObj = {};

export async function loadKKProperties(obj) {
  kkObj.spUrl = _spPageContextInfo.siteAbsoluteUrl;
  kkObj._KKRestHost = "https://ha----dev.com";
  kkObj._BaseHost = "https://in-url.com";
// other code

JS:

import { loadKKProperties } from "./helperfile";
import axios from "axios";

function getDocFolders(kkUser, places) {
  return kkUser
    .userValidatedPostRequest({
      // stuff
      }
    })
// more code

async function globalInitPromise() {
  const kkObj = await loadKKProperties(); 
  const token = await permissionToCallKKAPI(kkObj.hsHost);
  const kkUser = new KKUser(kkObj, token);

    class KKUser {
      constructor(kkObj, token) {
        this.kkObj = kkObj;
        this.token = token;
      }
// other code

userValidatedPostRequest(dataObj) {
    dataObj.Params.SAMAcct = this.kkObj.currentAccount;
    return axios
       .post(this.kkObj._KKRestHost + "/myAPI/api/Query/Post", dataObj, { // debugger gets stuck here
        "query": {
            "__metadata":{"type":"SP.CamlQuery"}
        },
        withCredentials: true,
        headers: {
          Accept: "application/json;odata=verbose",
          Authorization: this.token,
          "X-RequestDigest": $("#__REQUESTDIGEST").val()
        }
      })
// .then
// .catch

控制台:

  • 404错误

enter image description here

enter image description here

0 个答案:

没有答案