PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, October 14, 2022

[FIXED] How to import qs in react

 October 14, 2022     axios, reactjs, stringify     No comments   

Issue

I searched about [How to use qs in react] but can't find the answer.

Qs's official site https://www.npmjs.com/package/qs Usage

qs = require('qs');
var assert = require('assert');

var obj = qs.parse('a=c');
assert.deepEqual(obj, { a: 'c' });

var str = qs.stringify(obj);
assert.equal(str, 'a=c');

But I never see require() used in react.

Does anybody know this answer?

I need this for passing array parameter in axios.


Solution

I had this identical problem in my React.

This would work:

const qs = require('qs')

This wouldnt work:

import qs from 'qs'

I solved it by deleting the "@types/qs" section from my package-lock.json, then running

npm install


Answered By - Sean M
Answer Checked By - Pedro (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing