小编Raf*_*fid的帖子

axios.patch / axios.put在Vue和Laravel中不起作用

我的vue文件中有此代码

saveProfile() {
    axios.patch('/api/pegawai/' + this.id, {
         data: this.data
    })
    .then(function (response) {
         console.log(response);
    })
    .catch(function (error) {
         console.log(error);            
    });
}
Run Code Online (Sandbox Code Playgroud)

在我的laravel控制器中

public function update(Request $request, $id){
     return $this->sendResponse('request retrieved');
}

public function sendResponse($message){
    $response = [
        'success' => true,
        'message' => $message,
    ];
    return response()->json($response, 200);
}
Run Code Online (Sandbox Code Playgroud)

当我运行vue文件以将数据传递到控制器时,它应该给我一个具有以下值的浏览器控制台的json响应

{
  'success' : true,
  'message' : 'request retrieved'
}
Run Code Online (Sandbox Code Playgroud)

目前它500 internal server error通过浏览器控制台我一个错误。如果替换为axios.patch,我将得到相同的结果axios.put

--- 我试过的 ---

我已经尝试过axios.post并且axios.get …

http laravel vue.js axios

7
推荐指数
1
解决办法
6279
查看次数

在 Keycloak 的更新用户配置文件中添加自定义验证

login-update-profile.ftl我在named中添加了一个自定义属性organization,它能够将用户的输入保存到Keycloak中。

<div class="${properties.kcFormGroupClass!}">
    <div class="${properties.kcLabelWrapperClass!}">
        <label for="user.attributes.organization" class="${properties.kcLabelClass!}">${msg("organization")}</label>
    </div>
    <div class="${properties.kcInputWrapperClass!}">
        <div class="${properties.kcInputWrapperClass!}">
            <input type="text" id="user.attributes.organization" name="user.attributes.organization" value="${(user.attributes.organization!'')}" class="${properties.kcInputClass!}" aria-invalid="<#if messagesPerField.existsError('organization')>true</#if>"
            />
        </div>

        <#if messagesPerField.existsError('organization')>
            <span id="input-error-organization" class="${properties.kcInputErrorMessageClass!}" aria-live="polite">
                ${kcSanitize(messagesPerField.get('organization'))?no_esc}
            </span>
        </#if>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

如何为该字段添加验证?我需要将其设为必填字段并满足某些条件(例如字符串的长度)。如果输入无效,则会显示错误消息(就像我们在电子邮件或用户名字段中看到的那样)

jboss freemarker single-sign-on wildfly keycloak

7
推荐指数
1
解决办法
3403
查看次数

标签 统计

axios ×1

freemarker ×1

http ×1

jboss ×1

keycloak ×1

laravel ×1

single-sign-on ×1

vue.js ×1

wildfly ×1