dongliming2416 2017-04-13 22:14
浏览 76

PHP:由于传递了param类型而导致请求错误

So, my php is terrible being an FE engineer but need to fix something fairly quick.

I'm hitting an endpoint of an API that stack trace errors to/on this BE function:

/**
* 
* @param string $token
* @return \stdClass|null
*/
protected function getInstance(string $token)
 {
     $instance = PubSub::getInstance($token);
     return $instance;
 }

Here is my fe code that is hitting it (angular1):

$http({
    method: 'PUT',
    url: $rootScope.quizURI + '/API/quiz/control/timer',
    headers: {
        'Content-Type': 'application/json',
        'Authorization': $rootScope.teacher_token
    },
    data: {
        'instance_token': $rootScope.teacherInstanceToken
    }
    }).then(function successCallback(response) {
        $log.debug('response from control timer put', response);
    });

Workings:

  • Yes, $rootScope.teacher_token is a string.
  • Yes, here there's a response error in the browser console:

Fatal error: Uncaught TypeError: Argument 1 passed to API\Controller\Base::getInstance() must be of the type string, null given, called

Any pointers would make my Easter ;)

EDIT:

Blunder on my part. A var was undefined wa wa waaaaa

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 划分vlan后不通了
    • ¥15 GDI处理通道视频时总是带有白色锯齿
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)
    • ¥15 自适应 AR 模型 参数估计Matlab程序
    • ¥100 角动量包络面如何用MATLAB绘制
    • ¥15 merge函数占用内存过大
    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大