Http package, do I have to supply the ? myself?


#1

Hi,

When I use the http package, I would have suspected that the package would insert the ?after the URL. but it does not?

The query option replaces the query string of url. Parameters specified in params that are put in the URL are appended to any query string. For example, with a url of “/path?query” and params of {foo:“bar”}, the final URL will be “/path?query&foo=bar”.


#2

I got to this problem because I wanted to make my code neater:

old:

export function deleteStream(guid) {
    return HTTP.call('DELETE', 'http://' + config.host + '/' + config.virtualProxy + '/qrs/stream/' + guid + '?xrfkey=' + config.xrfkey, {
        headers: {
            'hdr-usr': config.headerValue,
            'X-Qlik-xrfkey': config.xrfkey
        }
    }, function(error, response) {
        if (error) {
            console.error(error);
            throw new Meteor.Error('error stream delete', error)
        } else {
            console.log(response);
            return response;
        }
    });

to new sync code on the server

 try {
        const result = HTTP.del('http://' + config.host + '/' + config.virtualProxy + '/qrs/stream/' + guid+'?', {
            headers: authHeaders,
            params: {
                'xrfkey': config.xrfkey
            }            
        })
        return result;
    } catch (err) {
        throw new Meteor.Error('Create stream failed', err.message);
    }

But when I do this I got failed [403] XSRF prevention check failed. Possible XSRF discovered. meaning the parameter XREF does not match the XREF in the header… Any ideas how I can see what is happening? (fiddler I know)