question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`merge` in utils convert an array post data to an object

See original GitHub issue

Summary

try

let url = '/dsk',
let data = {
    dsk: ['a1', 'a2']
}
let config = {
    baseURL: 'http://8.8.8.8',
    data
}

axios.post(url, data, {config}).then(resp => { console.log(resp.config.data) })

get resp.config.data

{"baseURL": "http://8.8.8.8", "url": "/dsk", "data": {"0": "a1", "1": "a2"}}

this config data is not expect.

Context

  • axios version: v0.18.0
  • Environment: node v10.4.1

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:6
  • Comments:6

github_iconTop GitHub Comments

4reactions
seedlinktech-williamcommented, Nov 29, 2018

I have met same situation. What I used for workaround is delete the data in config, like:

let url = '/dsk',
let data = {
    dsk: ['a1', 'a2']
}
let config = {
    baseURL: 'http://8.8.8.8',
    // data
}

axios.post(url, data, config).then(resp => { console.log(resp.config.data) })

When axios.post be invoked, it will check its arguments and compare the data with config.data. If config.data is false value, it will using the data directly. Then the merge will not be called.

0reactions
chinesedfancommented, Jan 31, 2020

Closed in favor of #2567.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Merge keys array and values array into an object in JavaScript
You can combine two arrays with map method, then convert it with Object.fromEntries .
Read more >
Merge Arrays into a New Object Array in Java - GeeksforGeeks
Given two arrays of the same type, they need to be merged into a new object array. The task is to merge the...
Read more >
How to Convert an Array to Comma Separated String in Java
The simplest way to convert an array to comma separated String is to create a StringBuilder, iterate through the array, and add each...
Read more >
array_merge - Manual - PHP
If the input arrays have the same string keys, then the later value for that key will overwrite the previous one. If, however,...
Read more >
Quickstart - Guzzle Documentation
The client constructor accepts an associative array of options: base_uri ... use GuzzleHttp\Psr7\Request; // Create a PSR-7 request object to send $headers ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found