Discussions » Development

关于GM_xmlhttpRequest

§
Posted: 2020-06-17

关于GM_xmlhttpRequest

如何使用GM_xmlhttpRequest,发送一次post请求,且"Content-Type": "application/json"。 试了很多方法都没有成功,难道只支持application/x-www-form-urlencoded 吗?

§
Posted: 2020-06-17
GM_xmlhttpRequest({
    method: 'POST',
    url,
    data : JSON.stringify(data),
    headers: {"Content-Type" : "application/json"},
    ...
})
§
Posted: 2020-06-17
Edited: 2020-06-17

@indefined 说道:

GM_xmlhttpRequest({
  method: 'POST',
  url,
  data : JSON.stringify(data),
  headers: {"Content-Type" : "application/json"},
  ...
})

GM_xmlhttpRequest({
        method: "POST",
        url: "https://wiki.cs.money/graphql",
        headers:{
                "Content-Type": "application/json"
                },
        data:JSON.stringify({
            "operationName": "price_on_cs_money",
            "variables": {
                "names": [
                    "CZ75-Auto | Red Astor (Factory New)"
                ]
            },
            "query": "query price_on_cs_money($names: [String!]!) {\n  price_on_cs_money(names: $names) {\n    name\n    price\n    float\n  }\n}\n"
        }),
        timeout:2000,
        onload: function(res){
            console.log(res.status);
        },
       onerror:function(err){
                            console.log(err.status);
                        }
    });

i tried it erro : 500,

wOxxOmMod
§
Posted: 2020-06-17

@LInkerH, date should be data and onerro should be onerror.

§
Posted: 2020-06-17

@wOxxOm 说道: @LInkerH, date should be data and onerro should be `onerror

OOOOOOOMG , THX!!!!

Post reply

Sign in to post a reply.