小编Maa*_*tje的帖子

Axios/XMLHttpRequest在生产环境中发送GET而不是POST

我遇到了一个非常奇怪的问题.我们正在将一个应用程序投入生产,其中一个POST请求变为POST,然后直接向同一URL发送GET请求,后端(Laravel)永远不会收到POST.在Chrome网络选项卡中,它看起来只是一个GET,但是使用Burpsuite,我们可以看到POST请求.

代码负责

async store() {
    // This prints post
    console.log(this.method());

    await this.form[this.method()]('/api/admin/users/' + (this.isUpdate() ? this.id : ''));

    if (!this.isUpdate()) {
        this.form.reset();
    }
},
Run Code Online (Sandbox Code Playgroud)

form.post方法的内容

return new Promise((resolve, reject) => {
    axios[requestType](url, this.data())
    .then(response => {
        this.busy = false;
        this.onSuccess(response.data);
        resolve(response.data);
    })
    .catch(error => {
        this.busy = false;
        if (error.response.status == 400) {
            return this.displayErrors(error.response.data)
        }
        this.onFail(error.response.data.errors);
        reject(error.response.data);
    });
});
Run Code Online (Sandbox Code Playgroud)

post get xmlhttprequest laravel axios

8
推荐指数
1
解决办法
3759
查看次数

Laravel迁移失败了多个主键

我试图在Laravel中创建一个Migration但是它没有说我有多个主键.

public function up()
{
    Schema::create('spins', function (Blueprint $table) {
        $table->integer('rid', true, true);
        $table->bigInteger('pid');
        $table->integer('result');
        $table->integer('bet');
        $table->timestamps();
        $table->primary(array('rid', 'pid'));
    });
}
Run Code Online (Sandbox Code Playgroud)

错误:

SQLSTATE[42000]: Syntax error or access violation: 1068 Multipleprimary key defined 
(SQL: alter table `spins` add primary key `spins_rid_pid_primary` (`rid`, `pid`))      
Run Code Online (Sandbox Code Playgroud)

migration primary-key laravel

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

laravel ×2

axios ×1

get ×1

migration ×1

post ×1

primary-key ×1

xmlhttprequest ×1